Static Linking MKL in Visual Studio 2010

Static Linking MKL in Visual Studio 2010

imagem de mkfreytag

Hello Anyone,

I'm using Visual Studio 2010 C++ w/ Intel Composer XE 12.1 to build a64-bit dll that incorporates calls to theMKL (10.3.11). For simplicity of deployment, I want to statically link inas many of the mkl libraries as possible.Based on output from thelink line advisor I've added mkl_intel_lp64.lib; mkl_intel_thread.lib; mkl_core.lib to the link line. However, no matter what I do, the libraries are not being statically linked. The linker insists on using the *_dll.lib versions.

What do I need to do to force Visual Studio / xilink to statically link this thing?

Thank you,
Michael

7 posts / 0 new
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de Ying H (Intel)

Hi Michael,

Could you please attach the small project to us so we can see what is the problem?

Best Regards,
Ying

imagem de mkfreytag

Hello Ying,
I sent you a PM.
Thank you,
Michael

imagem de Ying H (Intel)

Hi Michael,

I sawyour message, but the attached file is not there. Could you please upload it again? (you can addthe file by the "Add Files" button onup windows of reply)
(for third party libary, you may package the needed libraries to the project,).

Thanks
Ying

imagem de Ying H (Intel)

Hi Michael,

Thanks for the project. It is helpful. Let's me try to explain the cause.

There are two common ways to link MKL to an application.

1) manually link

It include 3 steps as the articl http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-compiling-and-linking-with-microsoft-visual-cc/
in Project Properties, Open the Propery Pages

1.1 Select the C/C++ General tab, In the Additional Include Directoriesline, add Intel MKL header filesinclude path (e.g. default: C:\Program Files\Intel\MKL\include).

1.2 Select the Link General tab, In the Additional Library Directoriesline, add Intel MKL library filespath(e.g. default: C:\Program Files\Intel\MKL\lib\intel64)
1.3 , Select the Link Input tab, In the AdditionalDependencies,add the requiredMKL libraries(e.g. common link: mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib).based on link line advisor.

As you see, you did the 3rd steps.

2) uing mkl intergated option in MSVC 2010. For example, below option.
You have the option is on too.

I upload the message in case of the page time out.

imagem de Ying H (Intel)

Continued,

The two kind of methods are equivalent in most of cases .so it is enough for select one of method. But in caseof you use themat the same time, the 2) has priority.

So that is why even if you link the static library manually, the project always ignore them.

Then let's talking about 2), why it link dynamic library.

Actually, the linked library is based on your choise of Run -time library (/MD multi-threaded dll, /MT Multi-thread (static). you can check the option in c/C++=>code generation =>Runtime library)

if it is /MD, then the mkl integration option will use dynamic library
if it is /MT , then the mkl integration option will use static library.

The option in your project is /MD, so mkl dynamic library are linked always.

Then for the solution, it should ok if you change the /MD to /MT for simple project.But as your application is based MFC dll and other third-party dll, your project will have to ask /MD option.

In such case, the bettersolutionlooks that to turn back manual link.

Please disable the option of method 2). (keep it as NO)
then add the header file path and library path manually as 1.1) and 1.2).

One more notes, the linked library : mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib (openMP library is needed and dynamic is recommend, so your dll may still depend on the libiomp5md.dll library)

Please try it and let us know if any result.

Best Regards,
Ying

imagem de mkfreytag

Hello Ying,
Thank you for the details. I suspected that the /MD option might have been the problem, but Ididn't see a way to get aroundit. I'll implement your suggestions in the coming days and let you know how things turn out.
Thank you,
Michael

Faça login para deixar um comentário.