Compiling and linking MKL with Xcode*


The following provides the information on linking Intel® Math Kernel Library with Apple* Xcode* development environment.

  1. Select Projects » Edit Active Target » select Menu "Build".
  2. Select Search Paths from Collection.
  3. Click User Header Search Path, and type in the directory for Intel® MKL include files (e.g. default:/Library/Frameworks/Intel_MKL.framework/Headers).
  4. Click Library Search Path, and type in the directory for Intel® MKL libraries path (e.g. default: /Library/Frameworks/Intel_MKL.framework/Libraries/em64t).
  5. Select Linking from Collection, click Other Linker Flags, and add linker flags for additional libraries. (e.g. -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread).

Note1: For the Intel® MKL for Mac OS* package, the Intel® MKL static and dynamic libraries are installed in the same directory / Libraries or /lib. And the static and dynmaic libraries use same name, for example, libmkl_core.dylib and libmkl_core.a . If use -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core, the standard linker used by Xcode* first chooses a dynamic library over a static library.  So if you need to use static, please link to the static libraries by using the full path and library name. e.g $MKLROOT/Libraries/em64t/libmkl_core.a.

Note2: If you link dynamic library for libmkl_intel.dylib, libiomp5.dylib, you may need to set the DYLD_LIBRARY_PATH environment variable in the Xcode environment.
To add the environment variable:
1. Expand the Executables heading under Groups and Files.
2. Select the executable produced from compiling with one of the compiler options mentioned above.
3. Click Info on the toolbar to display the Executable Info dialog box.
4. Under the Arguments tab, add DYLD_LIBRARY_PATH as an environment variable.
Set the Value as the full path to the Intel compiler's /lib directory and MKL directory
DYLD_LIBRARY_PATH=/opt/intel/Compiler/xx/xx/lib: /opt/intel/Compiler/xx/xx/Frameworks/mkl/lib/xx/

Since MKL 10.x, Intel Compiler for Mac OS intergate MKL as part of product. 
Please refer to Intel Compiler User and Reference Guide =>Building Applications with Xcode* IDE"
or "Configuring the Apple Xcode* Developer Software to Link with Intel MKL" section in MKL user guide  for more details. 

And refer to "Linking Your Application with Intel® MKL" section in the Getting Started document to understand which libraries required by your code.

 Two Samples:

1.  How to link application against Intel MKL using XCode IDE  - Manual link, please see the article: How to link application against Intel MKL using XCode IDE
2.  How to link application against Intel MKL using XCode IDE  - Quick link, please Quick Link Intel® MKL In Xcode* IDE: A Fortran Sample

Operating System:

Mac OS*
Pour de plus amples informations sur les optimisations de compilation, consultez notre Avertissement concernant les optimisations.