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

How to static link mkl2022 on win platform

xushuhao
Beginner
842 Views

Hello everyone:

I wrote a sample program about matrices multiply. I used the zgemm function of cblas in mkl. I wanted to link it staticly.  I tried many methods, but only dynamic link worked correctly. It seems that I can't link the program staticly.

My IDE is Visual Studio 2022, my mkl is oneapi 2022.

The dynamic link steps is as follow:

(1) project>property>Intel libraries for oneAPI>use onemkl>sequential

The static link steps is as follow:

(1) project>property>Intel libraries for oneAPI>use onemkl>sequential

(2) project>property>link>input>Additional dependencies add  mkl_intel_ilp64.lib mkl_sequential.lib mkl_core.lib

I desire to know how to static link the mkl. The dlls of mkl is to heavy.

My sample codes:

_____________________________________________________________

#include <iostream>
#include<complex>
#define MKL_Complex8 std::complex<float>
#define MKL_Complex16 std::complex<double>
#include <mkl.h>


int foo()
{
MKL_Complex16 _alpha[1] = { { 0.23, 3.11 } };
MKL_Complex16 _beta[1] = { { 1.2, -0.72 } };
MKL_Complex16 A[6] = { {1.56, 0.1}, {2.06, 0.38},{ 6.32, 0.43}, {-3.22, 0.4}, {-2.78, 1.15}, {3.01, 0.6} };
MKL_Complex16 B[12] = { {1.11, -1.0}, {2.45, 2.37}, {3.76, 0.0}, {6.32, 0.43}, {1.11, 1.0}, {2.45, 0.04}, {3.67, 0.8}, {6.32, 0.43}, {1.11, -1.0}, {2.45, 0.63}, {3.76, 0.0}, {6.32, 0.43} };
MKL_Complex16 C[8] = { {0.0, 0.0}, {0.0, 0.1}, {1.0, 0.1}, {1.0, 0.0}, {0.0, 0.0}, {0.0, 0.1}, {1.0, 0.1}, {1.0, 0.0} };
cblas_zgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 2, 4, 3, _alpha, A, 3, B, 4, _beta, C, 4);

for (int i = 0; i < 8; ++i)
{
std::cout << C[i].real << "," << C[i].imag << std::endl;
}

return 0;
}

int main()
{
foo();
}

______________________________________________________________________

Thanks for apply.

 

0 Kudos
3 Replies
ShanmukhS_Intel
Moderator
785 Views

Hi,


Thank you for posting on Intel Communities. Could you please check if the below configuration settings were given correctly under your Visual Studio properties page.


In C/C++ -> General -> Additional Include Directories C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\include


Under Linker-> General -> Additional Library Directories -> C:\Program Files (x86)\Intel\oneAPI\mkl\2022.1.0\lib\intel64


Various linking options were provided in below link which could help you.


https://www.intel.com/content/www/us/en/develop/documentation/onemkl-windows-developer-guide/top/linking-your-application-with-onemkl/linking-examples/linking-on-intel-64-architecture-systems.html


Could you please get back to us if you still face the issue after modifying the above settings.


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
745 Views

Hi,

 

A gentle reminder:

Has the information provided helped? Is your issue resolved?

 

Could you please let us know if you need any further information?

 

Best Regards,

Shanmukh.SS

 

0 Kudos
ShanmukhS_Intel
Moderator
725 Views

Hi,


We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Best Regards,

Shanmukh.SS


0 Kudos
Reply