Compiling and Linking Intel® Math Kernel Library with Microsoft* Visual C++*

The following provides hints for linking your program with Intel® MKL from the Microsoft* Visual Studio Environment: 

Microsoft* Visual Studio 2017/2015/2013/2012/2010 -- Automatically

Microsoft* Visual Studio 2017/2015/2013/2012/2010 -- Manually

Intel® MKL with Microsoft* Visual Studio 2017/2015/2013/2012/2010

Intel® Math Kernel Library could be installed as sub-component of Intel® Parallel Studio XE integrated into the Microsoft* Visual Studio* (MSVS). While user fully install the Intel® Parallel Studio or select Intel MKL manually to install, the math kernel library will be integrated into MSVS automatically. User could use Intel MKL wit your projects in MSVS Integrated Development Environment (IDE) by one step. In this section, using Intel MKL with MSVS 2017 will be discussed as an example, for Microsoft* Visual Studio 2010 and MSVS 2012, please follow the same guide.

Use Intel® MKL in Microsoft* Visual Studio 2017/2015/2012/2010 - Automatically

Step 1: Right click solution, select Properties» Configuration properties » Intel Performance Libraries » Use Intel® MKL; Figure 1 shows the screenshot of this step.

Figure 1. Using Intel MKL in MSVS 2017

Step 2: Change the Use MKL property setting by selecting Parallel, Sequential, or Cluster as appropriate, and apply this change to your project. The detailed information of each option is shown below:

-No: Disable use of Intel MKL libraries;
-Parallel: To link with a certain Intel MKL threading layer depending on the threading option of OpenMP or Intel® TBB;
-Sequential: To link with sequential version of Intel MKL;
-Cluster: To link with Intel MKL cluster components (sequential) that use Intel® MPI.

* Learn more about using OpenMP and Intel® TBB for parallel operation, please refer document of Using Intel® MKL with Threaded Applications; For using Intel MPI with MKL, please view Using Intel® MKL MPI wrapper with the Intel® MKL cluster functions.

Step 3 (Optional): For linking with static/ dynamic library, please right click your solution and select Properties » Configuration properties » C/C++ » Code Generation, set the runtime library value from following list:

-Multi-threaded (/MT): linking with static Intel MKL libraries
-Multi-threaded DLL (/MD): linking with dynamic Intel MKL libraries

* If user link with dynamic library, the execute file of your project should be required with dll files that you have to make sure the MKL has been installed in your running environment. Learn more information about linking MKL library, please see following documents:
Linking with Compiler Run-time Libraries
Libraries (libm.lib, libmmt.lib, libmmd.lib, libiomp5mt.lib, libiomp5md.lib, libirc.lib, libircmt.lib, svml_disp.lib, svml_dispmd.lib ...) provided by Intel® C++ Compiler for Windows and Intel Parallel Composer

Now, you could start your work with Intel MKL and test examples under the MKL root path. Or you could visit Intel® Math Kernel Library (Intel® MKL) Support to find more online sample codes of BLAS, FFT and LAPACK.


Use Intel® MKL in Microsoft* Visual Studio 2017/2015/2012/2010 - Manually

This section is the guide for setting to use Intel MKL in MSVS* manually. Normally, the Intel MKL path and DLL files could be added automatically, there is unnecessary to complete this section. User could use the "Step 1" to have a check. If the MKL path has not been inserted into include & library directories by default, please follow instructions below to make sure the MKL could be used in MSVS successfully. 

Step 1: Check and set the path of Include & Library Directories

  1.  In Project Property pages, select Configuration Properties » VC++ Directories; View Include Directories by editing this option. Make sure following path has been added into Include Directories:
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.***\windows\mkl\include
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.***\windows\mkl\include
    Also notice the Include path of Intel C++ Compiler should be added as well like following:
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.***\windows\compiler\include
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.****\windows\compiler\include\<arch>
    *The <arch> must be specified as "ia32" or "intel64"
  2. View Library Directories by editing this option. Make sure following path has been added into Library Directories:
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.***\windows\mkl\lib
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.***\windows\mkl\lib\<arch>_win

    Also notice the library path of Intel C++ complier should be added as well like following:
    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.***\windows\compiler\lib\<arch>_win
    *The <arch> must be specified as "ia32" or "intel64", the screenshot of Include Directories and Library Directories are shown in following Figure 2 and Figure 3:

Figure 2. Add MKL include path with application

Figure 3. Add MKL library path with application

Step 2: Link required MKL library into your project

Select the Linker » Input » Additional Dependencies, add the required MKL libraries (e.g. common link: mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib). The screenshot of adding additional dependencies of MKL library displayed in Figure 4.

* Generally, to link with Intel MKL, you may need to choose one library from the Interface layer and one library from the Threading layer and add the only library from the Computational layer and run-time libraries (RTL). See MKL Link Line Advisor

Figure 4. Link MKL library files as additional dependencies 

Step 3: Run script to set environment variables for Intel MKL (optional for DLL)

You can add Intel® MKL dll path either in your system environment setting by system Start Menu>> Right Click Computer >>Properties>> Advanced System setting >>Open System Properties Page >> Advanced >> Edit the system environment variables >>Add mkl dll path <parent product directory>\redist\<arch>\mkl\ to Path

Or do following instructions:

  1. Start with command prompt, run mklvars.bat <arch> [MKL_interface] [mod] from directory <mkl root path>\bin\ in one command window, (by default mkl root path should be like:C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.*.***\windows\mkl
  2. Then start < Microsoft Visual Studio>/IDE/devenv.exe in the same command windows. The detailed instructions can be found in following Figure 5.

​* Please view Setting Environment Variables to learn how to write command lines to run script. For more information about MKL directories structure, see High-level Directory Structure.

Figure 5. Run script to set environment variables

* For more settings of MKL using command lines, please visit Using the Custom Dynamic-link Library Builder in the Command-line Mode

Now, you could start your work with Intel MKL and test examples under the MKL root path. Or you could visit Intel® Math Kernel Library (Intel® MKL) Support to find more online sample codes of BLAS, FFT and LAPACK.

Note 1: for link MKL in Intel Fortran Or C++ Compiler for windows*, please refer to Using MKL in Intel® Compiler - mkl, Qmkl options

Note 2: Since from MKL 10.3 release, MKL is part of Intel Parallel Studio XE.  This provides an easy way to compile and link MKL in Parallel Studio XE environments. But the directory and integration has changed a bit compared to the previous releases (MKL 10.2 and earlier versions). Please see A new directory hierarchy in Intel MKL package .

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



Would be nice to get this article updated

First under MKL section, I'll get Use ILP64 interfaces which are not explained in this article. What that means and which effects that would have.

And second when you do choose Parallel it does not mention which of the many .DLL/LIBs it will actually link against, do. I do not mind blackboxes but it would be nice if they would be explained better. As it seem to be no problem at all to use Parallel and then just use the sequential MKL .dll seems to work. Which strikes me as a bit odd.

Who writes these guides? You all need to write an actual install help guide. It is beyond ridiculous that this is so difficult to link with the most current Visual Studio on the most recent OS using the most recent intel chip architecture. You also should provide an example of the flow by showing photos of you performing each step on your machine.

Questions regarding Intel® Math Kernel Library should be posted to the forums here:


Questions posted to Articles may or may not be responded to.


Regards, Hal

Intel(R) Developer Zone Support
*Other names and brands may be claimed as the property of others.

There is no such thing as "Properties» Configuration properties » Intel Performance Libraries " in my Project properties.
Is there a way to make it appear there? The manual instructions don't do anything basically. 

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.