Why do I get the error ‘Undefined function or variable detect while running standalone application compiled from Linux terminal?
조회 수: 3 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2017년 11월 9일
답변: MathWorks Support Team
2017년 11월 9일
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?
채택된 답변
MathWorks Support Team
2017년 11월 9일
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
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!