Dynamical linking with mex

I am compiling a C++ program using mex, in Mac OSX. The program is dynamically linked to various libraries. Compiling with g++ using the appropriate -I, -L, -l links works fine and the program runs. Using the same compilation line, with g++ replaced by mex, fails. Compilation is OK but at runtime the dynamical libraries are not found. Does mex use a different dynamical linker, with an environmental variable different from DYLD_LIBRARY_PATH? Or perhaps it uses a different shell (DYLD_LIBRARY_PATH is defined in my bash profile)?
Update:
The relevant part of the code is:
Lflags={['-L',intelroot,'/lib/'],['-L',mklroot,'/lib/']};
(mklroot and intelroot are the absolute paths to the root of the intel and MKL libraries folders).
lflags={'-lm', '-lpthread', '-liomp5', '-lmkl_intel_thread','-lmkl_core','-lmkl_intel_lp64'};
mex(VERBOSE,'-largeArrayDims', INCLUDES{:}, Lflags{:},lflags{:}, SRC{:});
The (MKL) libraries called are in DYLD_LIBRARY_PATH, as set in the Matlab startup file, using setenv (and verified by getenv), since apparently Matlab does not inherit the bash environment variables. The error message is: Library not loaded: libmkl_intel_thread.dylib.

3 件のコメント

Jan
Jan 2015 年 7 月 15 日
編集済み: Jan 2015 年 7 月 15 日
Please post the line you are using. Without seeing the command it is hard to guess if it contains an error. A copy of the error message might be useful also.
Dasharath Gulvady
Dasharath Gulvady 2015 年 7 月 21 日
MATLAB must be able to pick up files referenced using DYLD_LIBRARY_PATH? What is the error message you are receiving? Does it work fine if you provide the absolute path of the location of the files?
Please note that in order for -L option to work you need to set the run-time library path in Mac:
Moshe
Moshe 2015 年 7 月 24 日
編集済み: Moshe 2015 年 7 月 24 日
Thanks for the comments, I have updated the question, your help would be appreciated.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Compiler についてさらに検索

タグ

質問済み:

2015 年 7 月 14 日

編集済み:

2015 年 7 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by