Loading a library when the program runs

Hi,

I would like to use the MKL library from Intel in my program. So far, I've been able to compile the program using :
- Header Search Path : /opt/intel/composerxe/mkl/include
- Library Search Path : /opt/intel/composerxe/mkl/lib /opt/intel/composer_xe_2013_sp1.3.166/compiler/lib

The program compiles but when I try to run it, I get :

dyld: Library not loaded: libmkl_core.dylib
  Referenced from: /Users/fayard/Library/Caches/appCode30/DerivedData/LinearAlgebra-39aa396e/Build/Products/Debug/LinearAlgebra
  Reason: image not found

Using otool -L LinearAlgebra, I get :

...
Load command 12
cmd LC_LOAD_DYLIB
cmdsize 48

name libmkl_core.dylib (offset 24)
...

therefore, I don't have the full path to the library. What is the correct way to do it ?

Best regards,
François

3 comments

It might be interesting to know that the following code works from the command line :

clang++ -c -std=c++11 -DMKL_ILP64 -m64 -I$MKLROOT/include Matrix.cpp -o Matrix.o
clang++ -c -std=c++11 -DMKL_ILP64 -m64 -I$MKLROOT/include main.cpp -o main.o
clang++ -L$MKLROOT/lib -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -liomp5 -ldl -lpthread -lm Matrix.o main.o -o main

Of course, a lot of environment variables are set from the terminal, using an intel shell script. I don't really know where I should put -m64. Sorry for that, I am a real newbie with IDEs.

Best regards,
François

0

According to MKL user's guide please do the following:
1. Open your project that uses Intel MKL and select the target you are going to build
2. Add the Intel MKL include path "<mkl directory>/include" to the HEADER SEARCH PATH
3. Add the Intel MKL library path for the target architecture "<mkl directory>/lib/intel64" to the LIBRARY SEARCH PATH
4. Specify the linker options for the Intel MKL and system libraries to link with your application: for example, set OTHER LINKER FLAGS to  "-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread -lm"
5. (Optional, needed only for dynamic linking) For the active executable, add new environment variable DYLD_LIBRARY_PATH with the value of <mkl directory>/lib

Also please check http://stackoverflow.com/questions/7809699/cant-link-intel-math-kernel-library-to-xcode-because-there-is-no-intel-mkl-fram

By default, the compiler installs under "/opt/intel/" and "/opt/intel/composer_xe_2013_sp1" - directory containing symbolic links to subdirectories for the latest installed Intel® Composer XE 2013 compiler release

0

It works. Thanks for your help.

0

Please sign in to leave a comment.