Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6539 Discussions

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

Hugo
Beginner
3,272 Views

I am on High Sierra (OS X 10.13), and this is my first time I am using the Intel MKL. I want to compile the example shown here

https://software.intel.com/en-us/mkl-tutorial-c-multiplying-matrices-using-dgemm

using MKL 2018. As suggested by the example, I create a file with the name: dgemm_example.c, and then I compile it using

icc -mkl dgemm_example.c -o dgemm_example

When running it:

./dgemm_example

I get the following message:

dyld: Library not loaded: @rpath/libmkl_intel_lp64.dylib
  Referenced from: /Users/hesquivel/Desktop/./dgemm_example
  Reason: image not found
Abort trap: 6

I was wondering how to make this library be loaded and avoid the error.

Thank you,

Hugo

PS: I am using a MacBookPro14,3 (Intel Core i7, 3.1 GHz, Mid 2017).

0 Kudos
1 Solution
Zhen_Z_Intel
Employee
3,272 Views

Hi Hugo,

"-mkl" is threaded dynamic linking with MKL, you have to set environmental variable. Please Run shell script file to set environment variables, for example, setting lib path for compilers and libraries:

$source /opt/intel/compilers_and_libraries_2018.*.***/mac/bin/compilervars.sh <ia32|intel64>

or you could export $DYLD_LIBRARY_PATH by yourself.

export DYLD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2018.*.***/mac/compiler/lib:/opt/intel/compilers_and_libraries_2018.*.***/mac/mkl/lib:$DYLD_LIBRARY_PATH

Please follow these articles to view detail info:

Compiling and linking MKL with Xcode*
Intel® Math Kernel Library for Mac OS* X User's Guide

View solution in original post

5 Replies
Zhen_Z_Intel
Employee
3,272 Views

Hi,

1. Please check with DYLD_LIBRARY_PATH, if lib path of MKL and compiler are set correctly.
2. Please try to link with 
libiomp5.dylib and mkl lib path, 
icc -o dgemm_example dgemm_example.c -L$MKLROOT/lib -Wl,-rpath,$MKLROOT/lib -Wl,-rpath,$MKLROOT/../compiler/lib -mkl 

Best regards,
Fiona

bjwiley233
Beginner
816 Views

Hi Fiona,

Can you give an update for the new file structure in the newest oneapi compiler?  It's confusing to see old posts to new file structures.  For one thing, /path/to/mac/bin/compilervars.sh scripts no longer exists so you cannot run it.  Was this replaced by /opt/intel/oneapi/setvars.sh I am assuming?  Then also from $MKLROOT which is /opt/intel/oneapi/mkl and there are two versions of the compiler 2021.4.0 and latest so should it be $MKLROOT/latest/lib or $MKLROOT/../compiler/latest/lib?

 

Lastely if compiling instruction are cmake .. && make && make check and we get this error message during make check.  How far back do we need to go to set these variables.  I can check that myself but it would be nice is moderators and employees actually run the code provided in the forums if Intel has the ability to do that.  I think we need support (and this isn't just Intel) to go the extra mile to actually run the code that post in these forums.  If you already did that than you can disregard this comment

 

Brian

Hugo
Beginner
3,272 Views

Hi Fiona,

By executing:

echo $DYLD_LIBRARY_PATH

I get nothing.

Compiling dgemm_example.c with your command line makes the executable run as expected.

icc -o dgemm_example dgemm_example.c -L/opt/intel/mkl/lib -Wl,-rpath,/opt/intel/mkl/lib -Wl,-rpath,/opt/intel/mkl/../compiler/lib -mkl

I was wondering how I should define DYLD_LIBRARY_PATH to make the missing library be added automatically.

Thanks!

Hugo

Zhen_Z_Intel
Employee
3,273 Views

Hi Hugo,

"-mkl" is threaded dynamic linking with MKL, you have to set environmental variable. Please Run shell script file to set environment variables, for example, setting lib path for compilers and libraries:

$source /opt/intel/compilers_and_libraries_2018.*.***/mac/bin/compilervars.sh <ia32|intel64>

or you could export $DYLD_LIBRARY_PATH by yourself.

export DYLD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2018.*.***/mac/compiler/lib:/opt/intel/compilers_and_libraries_2018.*.***/mac/mkl/lib:$DYLD_LIBRARY_PATH

Please follow these articles to view detail info:

Compiling and linking MKL with Xcode*
Intel® Math Kernel Library for Mac OS* X User's Guide

Hugo
Beginner
3,272 Views

Hi Fiona,

Thanks a lot for the details and support. I think I am ready to begin using MKL on High Sierra.

Best,

Hugo

Reply