Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7222 Discussions

Static linking with MKL 9.1 and 10.0 (Windows)

AndrewC
New Contributor III
715 Views
I have had to switch from dynamically linking to MKL to static linking because of a conflict between our MKL version and various versions of Matlab when our main DLL module is called from a Matlab MEX file.

My understanding ( for 9.1) is that all I (should) have to do is link against mkl_c.lib instead of mkl_c_dll.lib and then no MKL DLL's at all are then required apart from libguide40.dll.

Yet I still see mkl_p4p.dll being loaded dynamically at run-time.

0 Kudos
3 Replies
Andrey_G_Intel2
Employee
715 Views

You are right, for switching from dynamical MKL usage to statical usage you need to link with mkl_c.lib instead of mkl_c_dll.lib. Looks strange what mkl_p4p.dll still loading. Maybe other Matlab components use this library?

And I have question for you: how you determine what mkl_p4p.dll is loaded?

0 Kudos
AndrewC
New Contributor III
715 Views
So it is clear mkl_p4p.dll should not be loaded and I need to find out why.

I am running in a standalone mode (without Matlab) under the Visual C++ 2005 debugger so I can see what DLL's are loaded when. When the application performs my first matrix operation that calls perhaps a lapack routine ( not sure as it is buried way down in a class library) , I see the mkl_p4p.dll from the MKL BIN directory get loaded dynamically( MKLin is in the PATH)

My link line includes mkl_c.lib mkl_lapack.lib mkl_solver.lib
0 Kudos
AndrewC
New Contributor III
715 Views
I have found the issue. Including mkl_lapack.lib in the link line causes the problem. If I remove that then the mkl_p4p.DLL is not loaded.
0 Kudos
Reply