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

Linking option for including mkl libraries statically.

Francis_R_2
Beginner
922 Views

Trying to build my binary by including the intel MKL libraries statically (on OS X).

I have explored the following options:

[1] using -lmkl_intel_ilp64, etc at the link stage but this dynamically links the libraries despite the .dylib's and .a's existing under /opt/intel/composer_xe_2013.0.088/mkl/lib.  The top rated answer on http://stackoverflow.com/questions/844819/how-to-static-link-on-os-x shows that in cases where the .dylib and .a appear in the same directory, the .dylib (shared linking) is used. 

[2] Manually adding the full paths to the MKL libraries to the link line.  I would not have to rely on fixed paths as I'm developing a cross platform application. 

I would like to use option [1] as its environment agnostic, but not have to physically remove/relocate the .dylib's so that the linker will be forced to use the static version.

0 Kudos
1 Reply
Ying_H_Intel
Employee
922 Views
Hi Francis, Yes, I can understand your request, we have same discussion in http://software.intel.com/en-us/articles/intel-math-kernel-library-for-mac-os-compiling-and-linking-with-xcode. Like under windows, if your project was setting /MT (static link), then we can link static MKL automatically. and under Linux -Bstatic -lmkl, link static MKL automatically too. but it seems a limitation by compiler and linker on Mac OS. They don't support -Bstatic option. Acutally,the option 2 seems the easy workaround so far. as you want to static link mkl, then the fixed path is only used one time. Once you set a valid path during development, then no more environment dependency. Best Regards, Ying
0 Kudos
Reply