Using Intel® MKL in Intel® Compiler - mkl, Qmkl options

The Intel® Compiler option “-mkl”, “Qmkl” options provide users a quick and efficient way to link Intel® Math Kernel Library (Intel® MKL) in an application. With the option, users are free from complex link command, and just need to add simple options to link Intel MKL.

-mkl, Qmkl: 
It is a compiler option, tells the compiler to link to certain parts of Intel MKL.

Linux* and OS X*:

[lib]: Indicates which Intel MKL library files should be linked. Possible values are:

  • parallel
    Tells the compiler to link using the threaded libraries in Intel MKL. This is the default if the option is specified with no lib.
  • sequential
    Tells the compiler to link using the sequential libraries in the Intel MKL.
  • cluster
    Tells the compiler to link using the cluster-specific libraries and the sequential libraries in the Intel MKL. Cluster-specific libraries are not available for OS X*.

OFF  The compiler does not link to the Intel MKL.

The below example are using Intel Fortran Compiler for Linux*, 64bit as sample. You may find the other equivalents for Windows* and OS X* by Intel® Math Kernel Library Link Line Advisor

Command line example
-mkl  (same as -mkl:parallel) 

$ ifort -o test test.f90 -mkl  [-static-intel]  if static linking.

$ifort -o test test.f90 -mkl:sequential  [-static-intel] if static linking.

$ifort -o test test.f90 -mkl:cluster  [-static-intel] if static linking

Intel MKL package also contains IDE integration with Microsoft Visual Studio*, which is an easy to add Intel MKL into the applications. Check the article here to learn more information:

Note:  If you are using 64bit integer in 64bit application, the quick compiler option or one button haven't covered it yet. Please add the library manually according to Intel® Math Kernel Library Link Line Advisor

For more combination, please also refer to Intel® Math Kernel Library Link Line Advisor

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


shoaib r.'s picture

OS: Windows

I am writing a batch script that will run different algorithms using MKL. When I give the path of the exe in the batch file, it returns an error "The program can't start because mkl_thread.dll" is missing from your computer. This however works fine when I run it using MS Visual Studio. 

Any help or suggestions ? 

anand b.'s picture

can some help in providing detailed commands for compiling sequentially 32 bit ARAPCK on 64 bit OS ubuntu 14.04, ifort 16.0.1 using intel MKL. i did           ifort *.f -c    then   ar q libarpack.a *.o

to create ar file of arpack. then linked my source codes to lapack and blas using following

ifort -O3 -static-intel -parallel -par-threshold0 -mkl=parallel -openmp -i8 -mkl=parallel -L/home/user/Desktop/lib/libarpack.a -w -o xyz a.f b.f c.f d.f e.f g.f90 h.f90 i.f90 k.f90 l.f90 m.f90 o.......f90

instead of creating executable file xyz i get some undefined references to  dsaupd and dseupd. obviously its due to incorrect commands used and linking

do i have to make changes in bash file to change/ fix  the the MKL enviornment... 

pl help.

thanks to all


Ying H. (Intel)'s picture

It looks there is some problem about your MKL integration with MSVS 2008.
The Error 28 error LNK2001: unresolved external symbol _dgetrf@24 InvertMatrix.obj itself means the wanted mkl library (like mkl_intel_c.lib mkl_sequential.lib mkl_core.lib) haven't been linked in your project correctly.

A simple solution is to link them manually, (please disable the /Qmkl:sequentail at the same time).
The following the steps in


Best Regards,

anonymous's picture

I forgot to mention, I am trying to build a DLL. Here is the command line for the Linker:
/OUT:"Debug\KernelFortran.dll" /NOLOGO /MANIFEST /MANIFESTFILE:"C:\Users\x\Documents\Visual Studio 2008\Projects\CadecFortranKernel\KernelFortran\Debug\KernelFortran.dll.intermediate.manifest" /DEBUG /PDB:"C:\Users\x\Documents\Visual Studio 2008\Projects\CadecFortranKernel\KernelFortran\Debug\KernelFortran.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"C:\Users\x\Documents\Visual Studio 2008\Projects\CadecFortranKernel\KernelFortran\Debug\KernelFortran.lib" /DLL

anonymous's picture

For completeness, this is the command line generated by VS 2008:
/nologo /debug:full /Od /gen-interfaces /warn:interfaces /iface:stdref /module:"Debug\\" /object:"Debug\\" /traceback /check:bounds /libs:static /threads /dbglibs /Qmkl:sequential /c
My Configureation is Debug, Win32
I have VS2880 SP1 and Intell 11.1.048, full installation on a Windows 7 64 bit, i5 processor.
What am I missing?

anonymous's picture

I wrote InvertMatrix.f90, as part of a Fortran 11.1.048 project in a VS 2008 SP1 solution.
It calls DGETRF from the MKL package.
When I try to Build, I get:
Error 28 error LNK2001: unresolved external symbol _dgetrf@24 InvertMatrix.obj
I already set the Configuration Properties> Fortran> Libraries> Use Intel Math Kernel Library: Sequential (/Qmkl:sequential)
What else can I do?

Ying H. (Intel)'s picture


The option "Use Intel Math Kernel Library" will do same steps as <<>> in quick way. You can use either the option or do all steps manually.

Please check Inte FORTRAN Compiler 11.0.066's user manual, if it mentioned the -mkl option, then it was supported in early version. If no, then have you installed latest mkl or other Intel compiler version on same machine?

Ying's picture

Thank you for the article. I am using Inte FORTRAN Compiler 11.0.066. I can see the "Use Intel Math Kernel Library" in my Property Pages. Though I tried to follow these steps:

too link the library to my compiler.

Have you any idea why it is so?


anonymous's picture

I had loose very time trying compile using mkl libs directly with no success, this article simplify all work.

Thanks for

Add a Comment

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