Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
15 Views

Problem linking mkl on visual c++ 2008 Express edition

I get the following link errors when I use the mkl function "sgesv" in my program in Visual C++ Express 2008 Express Edition on windows 32.

1>Linking...
1>RBF_matrixFill.obj : error LNK2019: unresolved external symbol "void __cdecl mallocCu(int,int * *,int *)" (?mallocCu@@YAXHPAPAHPAH@Z) referenced in function "void __cdecl RBF_matrixFill(void)" (?RBF_matrixFill@@YAXXZ)
1>RBF_matrixFill.obj : error LNK2019: unresolved external symbol "void __cdecl mallocCu(int,struct float3 * *,struct float3 *)" (?mallocCu@@YAXHPAPAUfloat3@@PAU1@@Z) referenced in function "void __cdecl RBF_matrixFill(void)" (?RBF_matrixFill@@YAXXZ)
1>RBF_matrixFill.obj : error LNK2019: unresolved external symbol "void __cdecl mallocCu(int,float * *,float *)" (?mallocCu@@YAXHPAPAMPAM@Z) referenced in function "void __cdecl RBF_matrixFill(void)" (?RBF_matrixFill@@YAXXZ)
1>RBF_matrixFill.obj : error LNK2019: unresolved external symbol "void __cdecl sgesv(int *,int *,float *,int *,int *,float *,int *,int *)" (?sgesv@@YAXPAH0PAM00100@Z) referenced in function "void __cdecl RBF_matrixFill(void)" (?RBF_matrixFill@@YAXXZ)
1>RBF_matrixFill.obj : error LNK2019: unresolved external symbol "void __cdecl outputData(float *,int,int,char *)" (?outputData@@YAXPAMHHPAD@Z) referenced in function "void __cdecl RBF_matrixFill(void)" (?RBF_matrixFill@@YAXXZ)
1>../bin/matrixFill.exe : fatal error LNK1120: 5 unresolved externals

I have added the code where I am getting the errors from below:

#include "mkl.h"
//utility includes (in common folder)
#include "fileIO.h"
#include "mallocCu.h"

extern void sgesv (int*, int*, float*, int*,int*,float*, int*, int*);

sgesv (&numnode, &nrhs, matforcpu, &numnode, ipvt, rhs, &numnode, &info);

if(print_mat){
outputData( matforcpu, numnode, numnode, mat_cpu_output );
}

mallocCu( numnode*numnode, &matfordev);
mallocCu( numnode, &cdev, c);
mallocCu( numnode, &nodedev, node);
mallocCu( numnode, &ncodedev, ncode);

To solve the problem, I put extern "C" before the sgesv function but then I get an error when I do that too.

Any help will be appreciated.
0 Kudos
3 Replies
Highlighted
Black Belt
15 Views

You are causing unnecessary problems by trying to add your own function declarations for the MKL routines. As you have seen, if you let the MKL functions be decorated with C++ conventions, you will see unsatisfied externals.

Take the right-royal road, compile using the recommended compiler and linker options, and report any problems.
0 Kudos
Highlighted
Beginner
15 Views

Can u explain further am a beginner. I followed the guidelines to compile and link mkl functions in ms visual c++. I have included all the necessary libraries. What do you mean by I have allowed the MKL functions to be decorated with C++ conventions? I even copied and pasted the sgesvExample from the intel website directly onto msv C++ and am still getting the same errors. Can you guide me in the right direction? Am using windows 32 and I have mkl 10.2.6.037. Thanks.
0 Kudos
Highlighted
Black Belt
15 Views

There is a section in the MKL User Guide called "Creating, Configuring and Running the Intel Visual Fortran Project". Read it and just follow the instructions there to build and run some of the MKL examples provided in your installation.

Keep in mind that MKL routines are intended to be called from C, rather than C++. If you want to call them from C++, the compiler has to be informed (through function prototypes) that the routines being called are C-callable routines.
0 Kudos