mkk
mkk

Reputation: 1043

matlab mcc compiled standalone executable: Unrecognized function or variable

I have the following file helloworld.m:

% helloworld.m
function helloworld
    fprintf('\n=============')
    fprintf('\nHello, World!\n')
    fprintf('=============\n')
end

the matlab runtime is in my path:

echo $LD_LIBRARY_PATH
:/usr/local/MATLAB/MATLAB_Runtime/v98/bin/glnxa64/

I run the compiler and it finishes without errors

Note: everything in my startup file is wrapped in an ~isdeployed() conditional:

Parsing file "helloworld.m" (referenced from command line).
Generating file "readme.txt".
Generating file "run_helloworld.sh".

ls
helloworld  helloworld.m  mccExcludedFiles.log  readme.txt  requiredMCRProducts.txt  run_helloworld.sh

Now I try to run it and it errors with a cryptic message:

./helloworld
Unrecognized function or variable 'helloworld'.

MATLAB:UndefinedFunction
Error: Unrecognized function or variable 'helloworld'.

Upvotes: 0

Views: 347

Answers (1)

mkk
mkk

Reputation: 1043

Looks like I needed to add the parent directory of the .m file that was being compiled, if not in the pwd. This works:

 mcc -m ./helloworld.m

Now run:

./helloworld 
=============
Hello, World!
=============

Upvotes: 1

Related Questions