Error LNK2019: unresolved external symbol _cblas_dgemm specified in _main function

I am using the Intel Math Kernel Library (MKL) on top of my Visual Studio C / C ++ compiler. I installed additional directories for additional inclusions, additional library directories, additional dependency variables to refer to the MKL library, but when I ran the code of the matrix multiplication example, I still got binding errors, can someone tell me what I missed there?

#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, p, i, j; double alpha, beta; m = 2000, p = 200, n = 1000; alpha = 1.0; beta = 0.0; A = (double *)mkl_malloc( m*p*sizeof( double ), 64 ); B = (double *)mkl_malloc( p*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*p); i++) { A[i] = (double)(i+1); } for (i = 0; i < (p*n); i++) { B[i] = (double)(-i-1); } for (i = 0; i < (m*n); i++) { C[i] = 0.0; } printf (" Computing matrix product using Intelยฎ MKL dgemm function via CBLAS interface \n\n"); cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, p, alpha, A, p, B, n, beta, C, n); mkl_free(A); mkl_free(B); mkl_free(C); printf (" Example completed. \n\n"); return 0; } 
+4
source share
2 answers

It's hard to say, since the source code is actually not that useful for linker errors. If the linker says that it cannot find the function, then you are not linking the correct libraries, regardless of whether the source was compiled or not.

One thing I would be looking for does not make sense to simply specify library directories, as they simply provide different search paths for searching when searching for libraries. You still need to specify the actual library with which you want to link.

This is one of the possible reasons based on the information in your question.

0
source

You can use the MKL Link line advisor . Alternatively, you can follow the steps in this link to link MKL with Microsoft Visual Studio.

0
source

All Articles