Why does my compiled application fail to run when some directories were specified as relative paths at compile time using MATLAB Compiler 4.0 (R14)?

1 view (last 30 days)
I have compiled a stand-alone application using MCC. Before compiling the application, I added some directories using a relative path syntax. An example of such a command would be:
addpath(genpath('.'));
which adds the current directory and all subdirectories to the path, but uses a relative path syntax. The application compiles without errors, and the appropriate files are included in the CTF archive. When I attempt to run the application, I receive an error of the form:
Undefined command/function 'mysub'.
Error in ==> myapp at 2
MATLAB:UndefinedFunction
where "mysub" is the name of a subroutine that is contained in one of the directories specified as a relative path, and "myapp" is the stand-alone application.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
There is a bug in MATLAB Compiler 4.0 (R14) in the way that relative paths are handled during compilation.
To work around this issue, all paths should be specified as full paths. Several MATLAB commands may be of interest in constructing these paths: PWD, which returns the current directory, FILESEP, which returns '/' or '\' depending on the operating system, and the FULLFILE command, which builds a full directory path from individual subdirectories.
For example, the current directory and any subdirectories can be added as full paths with the following command:
addpath(genpath(pwd));

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!