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

Random number routines (MKL-VSL) and linking during compilation

Debanjan_Mukherjee
582 Views
Hello,
I have a module wherein I have a gaussian random number generator (that uses the VSL Gaussian generator from MKL Library). I am using that module now to write a small program that generates 10 random numbers. I am now having a whole bunch of issues to link the programs together to create an executable. I am using Mac OSX with 64 bit architecture and Intel processor. Here is the shell script I am using:
The module: randomGenerator.f90
The program: testRandomGaussian.f90
The script:

#! /bin/sh

echo 'compiling an MKL random generator example'

MKLROOT=/opt/intel/composer_xe_2011_sp1.7.246/mkl/

MKLPATH=$MKLROOT/lib/

MKLINCLUDE=$MKLROOT/include/

DYLD_LIBRARY_PATH=$MKLPATH

ifort -c randomGenerator.f90 -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/intel64/lp64 -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5

ifort -c testRandomGaussian.f90 -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/intel64/lp64 -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5

ifort -L$MKLPATH -I$MKLINCLUDE -I$MKLINCLUDE/intel64/lp64 -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5 randomGenerator.o testRandomGaussian.o -o testRandomGaussian.out

The above creates the .out executable but when i run the .out file it ends up giving me an error saying:

dyld: Library not loaded: libmkl_intel_lp64.dylib
Referenced from: /Users/debanjanmukherjee/Workfiles/Work/Simple-particle-OOP/sources/./testRandomGaussian.out
Reason: image not found
Trace/BPT trap: 5
dyld: Library not loaded: libmkl_intel_lp64.dylib Referenced from: /Users/debanjanmukherjee/Workfiles/Work/Simple-particle-OOP/sources/./testRandomGaussian.out Reason: image not foundTrace/BPT trap: 5
Can someone please offer some help t show what I am doing wrong?
I can upload my codes too in case that is needed, but since the compilation completes I believe the code itself is okay and I have an error in the linking.
Many thanks
0 Kudos
3 Replies
mecej4
Honored Contributor III
582 Views
There is no problem with compiling or linking.

The problem is related to the loading of the dynamically loaded libraries when your a.out is run and reaches a point where routines in those libraries are invoked. If the MKL *.dylib libraries are not accessible (in Linux this may be achieved by setting $LD_LIBRARY_PATH, or by modifying the ldd configuration file). The error messages are from the dynamic library loader. In looks in the usual system directories and does not find the needed .dylib files.
0 Kudos
Debanjan_Mukherjee
582 Views
So what should I be doing to get this fixed ? Can I set LD_LIBRARY_PATH in Mac too ?
0 Kudos
Ying_H_Intel
Employee
582 Views
Hi Debanjan,

The error message dyld: Library not loaded: libmkl_intel_lp64.dylib means the system can't find the library.

So whatever in Xcode environment (either4.0 or 3.2.4)or in terminal environment, to define DYLD_LIBRARY_PATH environment variable is required.

You candefinethe variable eitherby mklvars.* or define the DYLD_LIBRARY_PATH manually.


Please refer to http://software.intel.com/en-us/forums/showthread.php?t=106397&p=1#189389

Best Regards,
Ying
0 Kudos
Reply