How to Build an Intel® MKL Application with Intel® Visual Fortran Compiler

This document describes the steps to build an Intel® MKL application with Intel® Visual Fortran Compiler XE for Windows* OS integrated with Microsoft Visual Studio* 2017

Software Requirement:

1. Intel® Visual Fortran Compiler XE for Windows* OS 18.0 or a later version
    The compiler must be installed and integrated correctly with Microsoft Visual Studio* 2017.

2. Intel® MKL 2018 or a later version
    Intel® MKL is included in the Intel® Parallel Studio XE suite, or standalone version.

3. Microsoft* Visual Studio 2017 

Step 1:  Select whether you are building  IA-32 or Intel® 64 application
Based on the target machine your application will run on, select:

IA32: 32-bit application for IA-32 architecture
Intel 64: 64-bit application for Intel® 64 architecture

For more information about IA-32 and Intel® 64 architectures, see this article.

When building 32bit or 64bit application within Microsoft VS* environment, check the Build→Configuration manager→ Active solution platform setting. It should be either “X86"  (which corresponds to 32bit application). or "X64" (which corresponds to 64bit application).

Step 2: Create one Intel MKL Visual Studioproject 

The Intel MKL package includes much of code examples ( c and fortran file), located in the examples subdirectory of the install directory. i.e C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\mkl\examples.

User can build one Intel Fortran Project based on one of sample Fortran files. See the way of build project in the article:

The attached zip file at the end of the article contains a MSVS* 2017 project (Intel® Visual Fortran Compiler XE for Windows* OS IA-32/X64 application) for your reference.

Step 3: Link to Intel® MKL in your project automatically - quick option /Qmkl:[parallel|sequential|cluster]

Note: Step 3 and the Step 4 (optional) are equivalent in most cases. Be sure to use only one of these options, don’t mix them. 

The latest Intel® MKL versions have a single 'Build' menu in MSVS* environment. Refer to the MSVS* screenshot below. Open Project → Property Pages →Fortran → Libraries →Use Intel Math Kernel Library. Select the desired option, such as /Qmkl:parallel or /Qmkl:sequential. Once selected all of environment settings and required libraries are ready for your project. Proceed to build and run the application.

Then click OK and build the project. In most of case, the setting should be enough for building a Fortran application based on Intel® MKL. But if you have some customized requirement  to link Intel MKL, then please refer to below manual step.

Step 4: How to link to Intel® MKL in your project manually (Optional)

Step 4.1: Select the wanted libraries to link from Intel® MKL 
Use the on-line Intel® Math Kernel Library Link Line Advisor to determine which libraries your application needs to link to, based on your platform settings.

Intel® Math Kernel Library Link Line Advisor will list the libraries you need to link to from Intel® MKL

IA32 Windows* application:
"mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib" are common libraries

Intel® 64 Windows* application: "mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib"

Step 4.2: link to Intel® MKL manually in your project
Follow these steps to add the include path, library path and Intel® MKL libraries listed by the Intel® Math Kernel Library Link Line Advisor.  

1. To add the include path manually refer to the MSVS* screenshot below. Open Project → Property Pages →Fortran →General. Type/Paste the library directory in the 'Additional Include Directories' field.

2. To add the library path manually refer to the MSVS* screenshot below. Open Project → Property Pages → Linker →General. Type/Paste the library directory in the 'Additional Library Directories' field.

Make sure to check the library path and enter the correct directory:

<MKL install dir>\ia32,  for IA-32 application
<MKL install dir>\intel64, for x64 application                                                                                                                                              

3. To add  the required libraries manually refer to the MSVS* screenshot below. Open Project → Property Pages → Linker → Additional Dependencies. Paste the libraries from the Intel® Math Kernel Library Link Line Advisor.

Code Sample:

The attached zip file contains a MSVS* 2017 project (Intel® Visual Fortran Compiler XE for Windows* OS IA-32 manually /X64 /Qmkl application) for your reference. does Real 1d DFT.


Some interface libraries (i.e. mkl_lapack95.lib mkl_blas95.lib fftw3xc_ms) may not Intel® MKL standard libraries, as such "Step 2 - quick option" does not support them.  You can add those libraries manually if you need to use them.


You may encounter the following errors when building the project:

1. "fatal error LNK1104: cannot open file 'mkl_xxx.lib'"
    Make sure the library is included in the library path and the path you enter in step 3 or step 4 is correct.

2. "error #7002: Error opening the compiled module file.  Check INCLUDE paths. [MKL_DFTI]."                                                        Add the header file mkl_dfti.f90 in your code, for example:

! Include to build module MKL_DFTI
INCLUDE 'mkl_dfti.f90'

before the code line

Alternatively, copy the mkl_dfti.f90 file to your project's source directory and include it in your project. 

Step 4.3. Can't run exe as lack of some *.dll run-time library 

If you link with dynamic library, the execute file will ask the *.dll at run time.  So you have to make sure the all of DLL exist in your running environment.

In most of cases, the installer will add the path of Intel software tools to system environment.  But if no, please add it manually,

for example, in Windows* 7

open Computer Property page(right click Computer)=> Advanced system settings=> Advanced Tab=>Environment Variables

In Path variables, to add run-time library path,  like C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\redist\ia32_win\mkl and C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\redist\ia32_win\compiler etc.

Package icon DFT_RtoCCS.zip14.49 KB
For more complete information about compiler optimizations, see our Optimization Notice.



Dear Ying,
I would like to generate a DLL library that calls MKL routines. The library is called from Java JNA interface. I am using Visual Studio 2012 with MKL ver 11 and Intel Fortran Composer XE 2013. I followed the instructions posted here but still the library still cannot be found from java. A module not found error is issued from Java.
I am able to call a DLL library that does not have any MKL routines from Java successfully. In fact if I comment these routines in the same Fortran code and then generate the DLL the Java program can call the library successfully. Only when the MKL routines are not commented the error appears.

So it seems that when Java runs the DLL it cannot link to the MKL libraries. At this point I am not sure whether I need to set my Java path to point to these libraries and if so which ones or there are different settings in Visual Studio that are more relevant to Composer 2013 edition of Fortran.
Thanks for your help,

I wanna run a finite element computer code (fortran 77): it is likely written in a modular way. al errors are corrected but some more errors related to the subroutines names and some variables in the part (variable declaration part) keep coming. I mean the compiler considers that the subroutines are as error and shows for every subroutine this kind of message:

Error 10 error LNK2019: unresolved external symbol _V1 referenced in function _VELOCITY VERFSAT.obj

Error 12 error LNK2019: unresolved external symbol _DUMP referenced in function _MAIN__ VERFSAT.obj

here: V1 is a variable (velocity)
VELOCITY and DUMP are subroutine names

Does anyone have an Idea about this issue ?

If the "Use Itnel Math Kernal Library" is not show. Then you may following the steps in <<how to use MKL in MSVC>> to add include path, library path, mkl library manually in to your project.

Step 3.2: I'm using Intel Fortran compiler (10.1.029). The option "Use Intel Math Kernal Library" is not shown in "Project PropertiesConfig. PropsFortranLibraries" dialog box. Is there a workaround?

Add a Comment

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