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

Runtime error when building with mkl dylib

xiang_c_
Beginner
616 Views

When I built my program with MKL statically (.a files), everything was fine. But, when I built the code with those .dylib files and ran it, I got following errors:

dyld: Symbol not found: _MKL_Detect_Cpu_Global_Lock
  Referenced from: /opt/intel/compilers_and_libraries_2017.4.181/mac/mkl/lib/libmkl_intel_lp64.dylib
  Expected in: flat namespace
 in /opt/intel/compilers_and_libraries_2017.4.181/mac/mkl/lib/libmkl_intel_lp64.dylib
Abort trap: 6

What does this usually imply? I tried to add the directory containing .dylib files into $PATH, but it didn't help.

 

0 Kudos
6 Replies
Zhen_Z_Intel
Employee
616 Views

Hi xiang,

' _MKL_Detect_Cpu_Global_Lock' is bss symbol defined in libmkl_avx*.dylib, libmkl_core.dylib, libmkl_mc.dylib, libmkl_mc3.dylib, libmkl_p4m.dylib & libmkl_p4m3.dylib

If you meet linage error with missing symbol that probably because the lib path of MKL is not being linked, please use '-L${MKLROOT}/lib' for your link line. You could also check with MKL advisor to generate your link line.

Bets regards,
Fiona

xiang_c_
Beginner
614 Views

Hi Fiona,

I'm sure I've added that path. Actually, the building process itself succeeded and the executable file was generated. These errors popped up when I ran the file.

Best,

Xiang

Ying_H_Intel
Employee
614 Views

Hi Xiang,

Have you run the mklvars.sh? 

Generally, run one code with mkl dynamic library, please check:

 add the path of lib<product>.dylib in system environment before run binary (The <product> could be "mkl" or "ipp"). There are two methods to realize the solution:

  • Run shell script file to set environment variables, for example, setting MKL:
    > /opt/intel/compilers_and_libraries_2017.*.***/mac/mkl/bin/mklvars.sh <ia32|intel64>
  • Or write command to set directly, for example, setting MKL:
    export DYLD_LIBRARY_PATH="/opt/intel/compilers_and_libraries_2017.*.***/mac/mkl/lib:$DYLD_LIBRARY_PATH

and let us know if it works.

Best Regards,

Ying

https://software.intel.com/en-us/articles/dyld-library-not-loadedlibiomp5dylib?page=1

xiang_c_
Beginner
614 Views

Hi Ying,

Thanks for your detailed instructions, it helped me to locate the problem. It is somehow due to my use of "find_library" command in cmake (weird). When I wrote out the full path of those libraries, the problem has gone. 

Thank you again!

Best,

Xiang

bjwiley233
Beginner
297 Views

No idea why this doesn't work for a simple, SIMPLE program below and I need to compile AND run with -lmkl_sequential because the library needs "_mkl_blas_caxpy".   And yes I ran oneAPI setvars.sh.

 

`icc -L${MKLROOT}/lib -lmkl_sequential -std=c11 /Users/brian/tools/test/apbs/src/.config/float_epsilon.c -o test.o`

 

 

 

#include <stdio.h>

int main()
{
    float floatEpsilon = 1.0;
    while(1.0 + floatEpsilon / 2.0 != 1.0)
        floatEpsilon /= 2.0;
    printf( "%e", floatEpsilon );
    return 0;
}

 

 

I get this error and it's very frustrating when it gets down to being this simple:

 

 

 

./test.odyld: lazy symbol binding failed: Symbol not found: _mkl_serv_core_register_cleanup
  Referenced from: /opt/intel/oneapi/mkl/2022.0.0/lib/libmkl_sequential.2.dylib
  Expected in: flat namespace

dyld: Symbol not found: _mkl_serv_core_register_cleanup
  Referenced from: /opt/intel/oneapi/mkl/2022.0.0/lib/libmkl_sequential.2.dylib
  Expected in: flat namespace

 

 

  

bjwiley233
Beginner
296 Views

GOT IT.  Forgot about -lmkl_core form the bindings form

 

Reply