Jamie - 2 months ago 23

Linux Question

I feel like this is a relatively basic question, but a solution seems to be beyond my Google-fu.

I have a matlab project in ~/project which references a matlab library (cplex) in a folder /s/cplex/matlab. I can successfully compile my application by calling addpath('/s/cplex/matlab') and then running my main() script.

I want to build my project as an executable so that it still can reference /s/cplex/matlab. Ideally, /s/cplex/matlab will be packaged into this executable so that it is portable.

My attempts at making this work have all been futile. I've pored through http://blogs.mathworks.com/loren/2008/08/11/path-management-in-deployed-applications/ and tried:

- Add /s/cplex/cplex/matlab to LD_LIBRARY_PATH before running the executable
- Add /s/cplex/cplex/matlab to LD_LIBRARY_PATH before starting MATLAB so that it is on the MATLAB LD_LIBRARY_PATH
- Add /s/cplex/cplex/matlab to the Shared Resources and Helper Files panel in MATLAB's deploytool
- Add /s/cplex/cplex/matlab to the MATLAB path via addpath() before compiling
- Add /s/cplex/cplex/matlab to the Package panel in MATLAB's deploytool

Through all of these attempts, the resulting executable could still not locate the cplex directory. What is the best way to link/package a matlab executable to its .m dependencies?

Answer

Ahah! Fixed it.

To anyone who had a similar problem, the problem was indeed with the @ symbols. I was using the AFS file system, which resolves @sys in a filepath to the machine/operating system pair. There there were '@sys' strings in my paths to keep it general-purpose, which MATLAB saw and misread as the keyword to denote a class folder.

I replaced all occurrences of '@sys' with the actual folder name, and MATLAB parsed them correctly. Note that this solution was not immediately obvious because the path I was using was a symbolic link to the full path with the '@sys' strings.