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

5 views (last 30 days)
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

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Feb 2023
Edited: MathWorks Support Team on 16 Apr 2023
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:

More Answers (0)

Categories

Find more on Search Path in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!