Compiled matlab function does not recognize 'hypercube' function from the 'Image Processing Toolbox Hyperspectral Imaging Library'

Hi,
I have a very simple matlab function that calls the hypercube function (Image Processing Toolbox Hyperspectral Imaging Library) to load hyperspectral data. The codeline is like this: hypercube('path/to/hyperfile.img'). When I run the function in the matlab console, everything works perfectly fine. However, after compiling and executing the function I get the following error: Unrecognized function or variable 'hypercube'
I'm using MATLAB R2021 on a linux server. The command to compile the matlab function is:
/usr/local/MATLAB/R2021b/bin/mcc -o hyper_test -W main:hyper_test -T link:exe -d build/ -v hyper_test.m
I tried something similar to solve the current problem: introducing the hypercube.m when compiling my function
/usr/local/MATLAB/R2021b/bin/mcc -o hyper_test -W main:hyper_test -T link:exe -d build/ -v hyper_test.m a - hypercube.m
but it didn't help. Would be great if someone has an idea how to solve this.
Thanx!

Answers (1)

Hi Iris,
'hypercube' function is a part of Image Processing Toolbox Hyperspectral Imaging Library which is a support package. To include support packages, try using the -Z option of mcc. You may try adding
-Z autodetect
Also, I notice in the question above, you have written "-v hyper_test.m a - hypercube.m". I believe you where trying to do "-a" and not "a -".
Hope this resolves the issue you are facing.

3 Comments

Hi Vinayak,
thanks a lot for your answer!
First: yes you are right about the typo... it suppose to be "-a"
I tried to add "-Z autodetect" to the mcc command, but unfortunately it still didn't work.
However, it worked when I added "-a /home/blaa_path_to/MATLAB/SupportPackages/R2021b" to the mcc command.
I get a few warnings during compiling my code like this:
[Warning: In
"/home/blup/Documents/MATLAB/SupportPackages/R2021b/toolbox/images/supportpackages/hyperspectral/+matlabshared/+supportpkg/+internal/+sppkglegacy/HYPERSPECTRAL.m",
"matlabshared.supportpkg.internal.sppkglegacy.SupportPackageRegistryPluginBase"
are excluded from packaging for the MATLAB Runtime environment according to the
MATLAB Compiler license. Either remove the file or function from your code, or
use the MATLAB function "isdeployed" to ensure the function is not invoked in
the deployed component.]
[Warning: In
"/home/blup/Documents/MATLAB/SupportPackages/R2021b/toolbox/images/supportpackages/hyperspectral/hyperui/+hyper/+internal/+app/+viewer/+hyperspectral/+display/+dialog/VariableDialog.m",
"create" could not be found during compilation. Verify that path related flags
(-N, -p, -I) are correctly used.]
But at the end it works...Not sure if I should be concerned about the warnings...
thanks and cheers!
Great to hear that the issue you were facing is now resolved. I was able to reproduce the issue in R2021b and would like to share that this issue has been fixed in the latest release of MATLAB.
Oh thats really good to know, since we planned an upgreat soon. Thanks for the info!

Sign in to comment.

Products

Release

R2021b

Asked:

on 2 Aug 2023

Commented:

on 11 Aug 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!