Why can't I start my MATLAB Compiler generated executable from a different directory using relative paths?

I have used MATLAB Compiler to generate a stand-alone application. However, I am unable to run the executable unless I call it from the same directory in which it resides. For example, I might try the following code in MATLAB, where “compiled” is a subdirectory of D:\Applications\MATLABR14\work\temp:
mcc -d compiled -m tempfile
!D:\Applications\MATLABR14\work\temp\compiled\tempfile.exe
However, this results in the following error:
ERROR: Cannot find the directory containing the 'tempfile' component,
which is required by this application. Make sure the directory containing
'tempfile.ctf' is on your dynamic load library path
(PATH on Windows, or LD_LIBRARY_PATH on Linux, for example), or your
application search path (PATH on both Windows and Linux).
Error initializing CTF Archive

 채택된 답변

MathWorks Support Team
MathWorks Support Team 2023년 2월 20일
편집: MathWorks Support Team 2023년 4월 16일
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
You are trying to start the executable from a different directory by specifying a relative path. However, this is not supported directly. If you start a program from one directory using a relative path, your actual working directory is not the directory of the executable. The working directory must be the same as the executable in order for the CTF-file to be found or else the directory containing your CTF-file must be on your system PATH as the error mentions. Therefore, to work around this issue, add the directory in which the executable resides to the system executable search path. For instructions on how to modify the system path on Windows, see:

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by