Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
setting library path on compiled app

Subject: setting library path on compiled app

From: Matt

Date: 27 Sep, 2012 19:33:07

Message: 1 of 3

I have a matlab application (on linux) that calls several Java classes directly, one of which references a *.so library. When I compile this code and run it on a different machine, I'm having trouble with the library path. When running the uncompiled version, I simply add the needed libraries to the librarypath.txt and everything works, however this librarypath appears no to be exported with the compiled code (which packages up all the needed jars and .so files) as I am getting unsatisfied link errors.

How do I set the library path such that matlab will recognize it in its compiled form?

Thanks in advance
Matt

Subject: setting library path on compiled app

From: Matt

Date: 27 Sep, 2012 22:10:08

Message: 2 of 3

Here is what I've already tried:

1. Packaging up the needed libraries using the '-a' option when executing mcc(...)

2. Adding the required libraries to the directory containing my compiled code (i.e. the directory containing <my app> and run_<my app>.sh.

3. Modifying librarypath.txt such that it points to where the library files will be when deployed on a different machine

4. Modifying the LD_LIBRARY_PATH of the target machine. I attempted this both by adding a line to the run_<my app>.sh and also using the setenv('LD_LIBRARY_PATH') as well as setenv('PATH')

In all cases, my compiled matlab code successfully recognizes and uses the java classes, but when the java attempts to make use of the .so file it cannot be located and the unsatisfied link error is thrown

Thanks,
Matt

Subject: setting library path on compiled app

From: Yair Altman

Date: 27 Sep, 2012 22:36:06

Message: 3 of 3

"Matt" wrote in message <k42is0$evl$1@newscl01ah.mathworks.com>...
> Here is what I've already tried:
>
> 1. Packaging up the needed libraries using the '-a' option when executing mcc(...)
>
> 2. Adding the required libraries to the directory containing my compiled code (i.e. the directory containing <my app> and run_<my app>.sh.
>
> 3. Modifying librarypath.txt such that it points to where the library files will be when deployed on a different machine
>
> 4. Modifying the LD_LIBRARY_PATH of the target machine. I attempted this both by adding a line to the run_<my app>.sh and also using the setenv('LD_LIBRARY_PATH') as well as setenv('PATH')
>
> In all cases, my compiled matlab code successfully recognizes and uses the java classes, but when the java attempts to make use of the .so file it cannot be located and the unsatisfied link error is thrown
>
> Thanks,
> Matt


In Matlab up to R2012a, place your librarypath.txt file in the startup folder of your executable (same trick as for a custom classspath.txt file). Note that the startup folder is not necessarily the same folder as the one holding the executable. Also check that you're not using relative paths within the file (Java doesn't like these...).

In R2012b the startup folder trick reportedly fails, still a bit sketchy on this, not much info or research on this. Try using a similar file called javalibrarypath.txt in the same location.

Yair Altman
http://UndocumentedMatlab.com
Read my Matlab-Java programming book
 

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us