Showing results for 
Search instead for 
Did you mean: 

dyld: Library not loaded: @rpath error and solution


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 and 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/ intel64
source /installation_path/mac/mkl/bin/ 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:


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,


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.



0 Kudos