Linking to external dynamic library with mex on Mac OSX 10.8.4

Hello, I am trying to link to an external dynamic library in R2012b running on Mac OSX 10.8.4. Running the following command
mex -I<path to header> -L<path to library> -v <filename> -l<libname>
yields an Undefined symbols for architecture x86_64: error. The DYLD_LIBRARY_PATH variable was set to include the library path. A simple test console applications utilizing library functions when built and linked to the library using gcc.
Does anyone have any ideas or advice, I have searched extensively for more information but have found no solution.
Thanks David

4 Comments

Is your MATLAB 64-bit, but the library 32-bit?
No, the library is compiled natively and is 64-bit. I managed to compile and link the mex file to the library under the following conditions:
1.) Both the library and mex file are compiled with the -c switch. If they are compiled with g++ or another c++ compiler the mex file compiles and links however MATLAB crashes at runtime with a name decorator error.
2.) the library must be in /usr/lib; even pointing the linker to the absolute library path still yields undefined symbols.
So is the issue resolved now? Also, does your MEX-file have a .cpp extension?
In order to avoid a runtime crash the MEX-file has to have a .c extension; .cpp results in a crash.
I will say semi-resolved, I would prefer to be able to utilize C++ dynamic libraries and not put a symlink in /usr/lib. I feel like I am missing something simple but maybe not.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Asked:

on 1 Jul 2013

Community Treasure Hunt

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

Start Hunting!