The following provides hints for linking your program with oneMKL from the Microsoft* Visual Studio Environment:
Microsoft* Visual Studio 2017/2015/2013/2012/2010 - Automatically
Microsoft* Visual Studio 2017/2015/2013/2012/2010 - Manually
oneMKL with Microsoft* Visual Studio 2017/2015/2013/2012/2010
oneMath Kernel Library could be installed as sub-component of Intel® oneAPI Base & HPC Toolkit integrated into the Microsoft* Visual Studio* (MSVS). While user fully install the Intel® Parallel Studio or select oneMKL manually to install, the math kernel library will be integrated into MSVS automatically. User could use oneMKL wit your projects in MSVS Integrated Development Environment (IDE) by one step. In this section, using oneMKL with MSVS 2017 will be discussed as an example, for Microsoft* Visual Studio 2010 and MSVS 2012, please follow the same guide.
Use oneMKL in Microsoft* Visual Studio 2017/2015/2012/2010 - Automatically
Step 1: Right click solution, select Properties » Configuration properties » Intel Performance Libraries » Use oneMKL; Figure 1 shows the screenshot of this step.
Figure 1. Using oneMKL 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 oneMKL libraries;
-Parallel: To link with a certain oneMKL threading layer depending on the threading option of OpenMP or Intel® TBB;
-Sequential: To link with sequential version of oneMKL;
-Cluster: To link with oneMKL cluster components (sequential) that use Intel® MPI.
* Learn more about using OpenMP and Intel® TBB for parallel operation, please refer document of Using oneMKL with Threaded Applications; For using Intel MPI with oneMKL, please view Using oneMKL MPI wrapper with the oneMKL 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 oneMKL libraries
-Multi-threaded DLL (/MD):linking with dynamic oneMKL 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 oneMKL and test examples under the MKL root path. Or you could visit Intel® oneAPI Math Kernel Library (oneMKL) Support to find more online sample codes of BLAS, FFT and LAPACK.
Use oneMKL in Microsoft* Visual Studio 2017/2015/2012/2010 - Manually
This section is the guide for setting to use oneMKL in MSVS* manually. Normally, the oneMKL 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
- 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\<arch>
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" - 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 oneMKL, 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 oneMKL (optional for DLL)
You can add oneMKL 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:
- 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)
- 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 oneMKL and test examples under the MKL root path. Or you could visit Intel® oneAPI Math Kernel Library (oneMKL) 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® oneAPI Base & HPC Toolkit. This provides an easy way to compile and link MKL in Intel® oneAPI Base & HPC Toolkit environments. But the directory and integration has changed a bit compared to the previous releases (MKL 10.2 and earlier versions).
Additional Resources
Using MKL in Intel® Compiler - mkl, Qmkl options
How to build oneMKL application in Intel Visual Fotran (MSVC*2005)