I have a single mex file a.mexglx that needs to be linked dynamically
against a library libb.so. Compiling goes fine, mex finds the header
files of the library. But when I call !ldd a.mexglx | grep libb.so
from Matlab I get
libb.so => not found
I have the library in the same directory than the mex file, I have
compiled with the command
mex -L. -lb a.cpp
and I have tried adding . to both the system path and Matlab path.
Still nothing. Any ideas on how to find the problem? And, by the way,
how can I link mex files with a library that does not have a name
lib*.so?
Thanks.
Is the folder containing libb.so in your LD_LIBRARY_PATH?
You can check that via "getenv LD_LIBRARY_PATH" before
calling the mex-function.
Also, people might be able to help you better if you tell us
what the error message is when you try to call the mex-file.
I suppose you get unresolved symbols?
Joachim
>
> Thanks.
>
You can also add hardcode the directory location into the MEX file
using the linker command -rpath. Google for syntax. You'll probably
have to execute the link command by hand: use mex -v to see the full
gcc command line, copy-and-paste it, modify as appropriate, and run
it.
Or add the directory to the system ld.so.conf (/etc/ld.so.conf or the
directory /etc/ld.so.conf.d) and run ldconfig. All as root of course.
-Peter
setenv $LD_LIBRARY_PATH <directory>
matlab
it worked. I already have to use the script to set LD_PRELOAD correctly
before running matlab so it doesn't really matter that much.
Thanks!
These are good advice, I've been wondering how to use make to create the mex
files easily. That mex -v could help in that.
> Or add the directory to the system ld.so.conf (/etc/ld.so.conf or the
> directory /etc/ld.so.conf.d) and run ldconfig. All as root of course.
Well, I don't have root rights in my lab, so...