Using mkl with Visual Fortran

Hello,

This may appear as a very basic question, but how can I use mkl with a Visual Fortran program? I have a license for mkl (and an installation directory for the various libraries), but when I tried to build my program I got the message :

LINK : fatal error LNK1104: cannot open file ‘mkl_intel_lp64.lib’

Assuming that my compiler cannot see “by default” the locations of the mkl library, can you please explain to me how I can point the compiler to the directory containing the mkl files?

Thank you in advance for your help!

Hi IKoutromanos,

There’s a property setting under “Fortran->Libraries->Use MKL” which you can set. See: https://www.pgroup.com/resources/docs/18.4/x86/pvf-ref-guide/index.htm#pvf-prop-fort-libraries
This in turn adds the “-Mmkl” flag to the compiler which will then check the Windows registry for the MKL installation directory.

To see what directory the compiler is using, you can run the following from a command line shell:

PGI$ pgfortran  -Mmkl -dryrun x.obj
...
Writing to file \tmp/pgfortran-tempfile.lnk
C:\PROGRA~1\PGI/win64/18.1/lib\pgimainmx.obj C:\PROGRA~1\PGI/win64/18.1/lib\f90main.obj -incremental:no -debug -nologo -merge:__nv_module_id=.data -merge:.nvFatBinSegment=.data "-libpath:C:/Program Files/PGI/Microsoft Open Tools 14/Lib/AMD64" "-libpath:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/ucrt/x64" "-libpath:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/um/x64" -libpath:C:\PROGRA~1\PGI/win64/18.1/lib x.obj -out:x.exe -pdb:./x.pdb "-libpath:C:/Program Files/Intel/MKL/10.2.6.037/em64t/lib" -defaultlib:mkl_intel_lp64 -defaultlib:mkl_pgi_thread -defaultlib:mkl_core -defaultlib:libiomp5mt /DYNAMICBASE:NO -defaultlib:libpgmp -defaultlib:pg -defaultlib:libpgf90rtl -defaultlib:libpgf90 -defaultlib:libpgf90_rpm1 -defaultlib:libpgf902 -defaultlib:libpgf90rtl -defaultlib:libpgftnrtl -nodefaultlib:msvcrt -defaultlib:libvcruntime -defaultlib:libucrt -defaultlib:libcmt -defaultlib:libpgc14 -defaultlib:libnspgc -defaultlib:legacy_stdio_definitions -defaultlib:oldnames

"C:/Program Files/PGI/Microsoft Open Tools 14/bin/amd64\link.exe" /NOLOGO @\tmp/pgfortran-tempfile.lnk

C:\PROGRA~1\PGI/win64/18.1/bin\pgstrp.exe ./x.exf x.exe ./x.dwf
Keeping \tmp/pgfortran-tempfile.lnk
Keeping ./x.exf

So in my case, the compiler correctly finds MKL installed in “-libpath:C:/Program Files/Intel/MKL/10.2.6.037/em64t/lib” and then adds three libraries: “-defaultlib:mkl_intel_lp64 -defaultlib:mkl_pgi_thread -defaultlib:mkl_core”.


Are you using the “-Mmkl” flag? If so, then is the compiler finding the correct installation?

  • Mat

Thank you Mat.

Yes, I do ask the compiler to use mkl. The trouble is, that I get the following error from the Linker:

LINK : fatal error LNK1104: cannot open file ‘mkl_intel_lp64.lib’

What could be the reason for this, and how could I resolve it?

I also need to mention that I have not separately installed mkl in my computer. Instead, I have an older installation of Intel Visual Fortran, which includes the mkl libraries.

I need to add that I followed the procedure you described, and my compiler is listing an incorrect path for mkl.

Ok, so then it’s an MKL installation issue where the registry entry to its directory is incorrect.

Under the project property pages’ “Linker->Command Line”, you can manually add the correct path via a “-L<path/to/mkl>” in the “Additional Options” box.

-Mat

OK, thank you. I now get the message:

LINK : fatal error LNK1104: cannot open file ‘mkl_pgi_thread.lib’

Is PGI only compatible with specific versions of the mkl? If yes, which versions are these?

I don’t use MKL myself, so don’t know. However, according to their online docs they support PGI on Windows:

Unfortunately, I don’t see any more detail online. Do they mention anything in the documentation that accompanies MKL?

-Mat

I guess I can try replacing the use of mkl. Is there a subroutine that I could use to solve a system of equations with a sparse coefficient array, using multiple threads? This was the only reason for which I had to use mkl.