How to link application against Intel MKL using XCode IDE

From this article you will learn how to link Intel Math Kernel Library against your application under XCode Integrated Development Environment.

That tutorial is intended for XCode 3.1 but we hope that it will be helpful for users of the other versions.

Let the subject of our experiments will be example for the Laplace 2D solver from MKL Poisson solvers.

1. First of all create new 'Standard Tool' application with name 'mkl_project'. Remove 'main.c' file generated by XCode and add 'd_Laplace_2D_c.c' from 'mkl/examples/poissonc/source' directory into 'Source' project folder. Below the project for IA-32 architecture has been shown. Please refer to XCode documentation on how to change target architecture.

2. Double click on the target 'mkl_project'. 'Target 'mkl_project' Info' dialog should appear on the screen. If you woluld like to use Intel C++ Compiler for building your project find the rule for C source files on the 'Rules' tab and select 'Intel C++ Compiler 11.1' (*):

3. On the 'Build' tab in 'Search Paths' section add Header search Paths and Library Search Paths:

4. Finally to build your application you should add required libraries into 'Linking' section, field 'Other Linker Flags'. You may want to use 'MKL Link Line Advisor' tool (http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/) to determine what set of libraries is more suitable for you:

5. Perform building of your project by clicking 'Project>Build' XCode menu item.

6. To start resulting application you should open Terminal and define DYLD_LIBRARY_PATH environment variable like this: bash-3.2 % export DYLD_LIBRARY_PATH=/opt/intel/Compiler/11.1/084/Frameworks/mkl/lib/32

7. Now your application is ready for launch:bash-3.2 % ./mkl_project

* Note: the Article is relevant to the latest version of Intel C++ Compiler v.13.0. In that case all paths indicated above should be changed by Compiler/13.0/088 name. For example for  #6: DYLD_LIBRARY_PATH would be == /opt/intel/Compiler/13.0/088/Framework/mkl/lib/32 

For more complete information about compiler optimizations, see our Optimization Notice.
Tags: