Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28435 Discussions

dyld: Library not loaded: @rpath error and solution

César_B_
Beginner
1,044 Views

Hi,

While compiling some openmp and mkl code I've found the following error

dyld: Library not loaded: @rpath/libmkl_intel_lp64.dylib

I've only used the -O3 and -mkl flgas. 

 

This error has to do with some OS X El Capitan security policies where a plain installation sometimes doesn't load library paths.  So you have to source both mklvars.sh and compilervars.sh that are in the /opt/intel/compilers_and_libraries_v/ Where v is the version of your compiler.  Lets call that folder /installation_path/.  So you source those files with

source /installation_path/mac/bin/compilervars.sh intel64
source /installation_path/mac/mkl/bin/mklvars.sh intel64

A couple of times this was all that was necessary but sometimes it failed. I still got that dyld error. So I looked in the forums  and they advise you to use the Intel MKL line advisor. The advisor gives you a lot of flags but the one that solved the libmkl_intel_lp64.dylib issue was:

-Wl,-rpath,${MKLROOT}/lib

Which is a flag that tells ifort to pass a flag for the linker which shows it the path that is missing.

But then I found the following error:

dyld: Library not loaded: @rpath/libiomp5.dylib

So I searched for the path of libiomp5.dylib library, and added the following flag that the advisor doesn't give you explicitly, but you do the same trick,

-Wl,-rpath,$MKLROOT/../compiler/lib/

And the program is working.

In conclusion:

If you find some dyld: Library not loaded errors using openMP and mkl libraries with the -mkl flag; load the paths of compiler libraries sourcing the compiler and mkl vars, then pass the following flags to the compiler at the end of the file list. That is, you can use the following ifort call

ifort -mkl files.f90 -Wl,-rpath,${MKLROOT}/lib -Wl,-rpath,$MKLROOT/../compiler/lib/

If you found the same linking error look for some other library. Find the path of the library and then add the analog flag to ifort.

Cheers,

César.

0 Kudos
0 Replies
Reply