Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

## I can't run MKL with Visual studio.

Beginner
788 Views

Hello!

I installed on my computer Intel® C++ Studio XE for Windows 2013 SP1 and Microsoft Visual Studio Pro 2012. Then I followed the instructions that I watched on this video http://software.intel.com/en-us/videos/using-the-intel-c-compiler-with-microsoft-visual-studio-2012. In order to use MKL  I followed these instructions

For the Visual Studio* 2010/2012 development system:

1. Go to Project>Properties>Configuration Properties>Intel Performance Libraries.
2. Change the Use MKL property setting by selecting Parallel, Sequential, or Cluster as appropriate.

I wanted to run the following example that I read on the tutorial
```/* C source code is found in dgemm_example.c */

#define min(x,y) (((x) < (y)) ? (x) : (y))

#include <stdio.h>
#include <stdlib.h>
#include "mkl.h"

int main()
{
double *A, *B, *C;
int m, n, k, i, j;
double alpha, beta;

printf ("\n This example computes real matrix C=alpha*A*B+beta*C using \n"
" Intel® MKL function dgemm, where A, B, and  C are matrices and \n"
" alpha and beta are double precision scalars\n\n");

m = 2000, k = 200, n = 1000;
printf (" Initializing data for matrix multiplication C=A*B for matrix \n"
" A(%ix%i) and matrix B(%ix%i)\n\n", m, k, k, n);
alpha = 1.0; beta = 0.0;

printf (" Allocating memory for matrices aligned on 64-byte boundary for better \n"
" performance \n\n");
A = (double *)mkl_malloc( m*k*sizeof( double ), 64 );
B = (double *)mkl_malloc( k*n*sizeof( double ), 64 );
C = (double *)mkl_malloc( m*n*sizeof( double ), 64 );
if (A == NULL || B == NULL || C == NULL) {
printf( "\n ERROR: Can't allocate memory for matrices. Aborting... \n\n");
mkl_free(A);
mkl_free(B);
mkl_free(C);
return 1;
}

printf (" Intializing matrix data \n\n");
for (i = 0; i < (m*k); i++) {
A = (double)(i+1);
}

for (i = 0; i < (k*n); i++) {
B = (double)(-i-1);
}

for (i = 0; i < (m*n); i++) {
C = 0.0;
}

printf (" Computing matrix product using Intel® MKL dgemm function via CBLAS interface \n\n");
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
m, n, k, alpha, A, k, B, n, beta, C, n);
printf ("\n Computations completed.\n\n");

printf (" Top left corner of matrix A: \n");
for (i=0; i<min(m,6); i++) {
for (j=0; j<min(k,6); j++) {
printf ("%12.0f", A[j+i*k]);
}
printf ("\n");
}

printf ("\n Top left corner of matrix B: \n");
for (i=0; i<min(k,6); i++) {
for (j=0; j<min(n,6); j++) {
printf ("%12.0f", B[j+i*n]);
}
printf ("\n");
}

printf ("\n Top left corner of matrix C: \n");
for (i=0; i<min(m,6); i++) {
for (j=0; j<min(n,6); j++) {
printf ("%12.5G", C[j+i*n]);
}
printf ("\n");
}

printf ("\n Deallocating memory \n\n");
mkl_free(A);
mkl_free(B);
mkl_free(C);

printf (" Example completed. \n\n");
return 0;
}```

But I can't run it. The results I got are

Warning    1    warning D9025: overriding '/D__INTEL_COMPILER=1400' with '/U__INTEL_COMPILER'
Warning    2    warning D9002: ignoring unknown option '/QaxSSE4.2'
Warning    3    warning D9002: ignoring unknown option '/QxAVX'
Warning    4    warning D9002: ignoring unknown option '/Qfast-transcendentals'
Error    5    error C1083: Cannot open include file: 'mkl.h': No such file or directory

Could you please tell what I have done wrong?

4 Replies
Black Belt
788 Views

Right click on the project containing the source file, and select Properties. In the xxxapp Property Pages, select Configuration Properties->"Intel Performance Libraries" and set one of the options under "Intel Math Kernel Library".

If you do not see "Intel Performance Libraries" as described above, the Visual Studio integration for Intel C has not been properly installed. You will need to rectify that if you want to use Intel C.

If you want to use MKL with Microsoft C, the procedure is a little bit different, but straightforward -- it is the same as for using any third party C library in Visual Studio.

Beginner
788 Views

There are 3 options: Parallel, Sequential, Cluster. But it doesn't work. Please, do you have something to propose in order to find out what is  going wrong?

Moderator
788 Views

one of the problem may be ( we need to check it ) the issue with integration to VS2012.

but to start working, you can explicitly to add the path to the mkl header files into C.C++/General/Additional Include directories

it should help with this problem.

Employee
788 Views

Hi GF G.

Yes, you should be able to solve the problem by adding mkl header file path, library and library path manualy as Gennady mentioned.

Or you may open the verbose by property => C++ => General => Supress Startup banner  to NO

And property page => Linker=> general => Show progress to For Libraries Searched (/VERBOSE:Lib).

Clean your project and rebuild it , then check the buildlog to see what is going wrong.

Best Regards,

Ying