Why do I get the error ‘Undefined function or variable detect while running standalone application compiled from Linux terminal?

3 views (last 30 days)
I am trying to run MATLAB compiled code which includes the 'detect.m' 
function from the Computer Vision System Toolbox. It gave the following 
error - ‘Undefined function or variable 'detect'.' 
I am compiling using mcc from Linux Terminal and tried to add the path of the detect.m file to the Makefile and compiled it 
again. It gave the following error – 'Could not determine type of the 
MATLAB file detect.m'. Please make sure that you are compiling MATLAB 
Program files.' 
When I compile program from applicationCompiler,  it works fine. Perhaps because my main file has dependency on another file(load_my_data.m) which calls trainACFObjectDetector()and detect() from Computer Vision Toolbox.
When the directory where load_my_data.m reside is added to MATLAB search PATH, and I compile program from application compiler, everything works fine. But when I use the same mcc command and compile from terminal, I get the undefined function error.
How to make it work when compiling from terminal?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 9 Nov 2017
You are able to compile and run code from MATLAB because you are adding path (of the file that calls Computer Vision Toolbox functions) to MATLAB search path before compiling and hence the file is being scanned by Dependency Analyzer.
In case of compiling using mcc from Linux terminal, dependency analyzer could not find the file  and hence does not include Computer Vision Toolbox in your deployable archive. Since Computer Vision Toolbox is not present in deployable archive, while running program, it complains about  Undefined function or variable detect.
In order to add functions to your deployable archive, please use -a flag with your mcc command.
 
mcc -m myprogram.m -a trainACFObjectDetector.m
 

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!