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

Help with linking MKL with VS2010unresolved external symbol

Yuzhuo_Su
Beginner
311 Views
I am having the follwoing example code:

#include "mkl.h"
#include

#define N 5
void main()
{
MKL_INT n = N, inca = 1, incb = 1, i;
MKL_Complex16 a, b, c;
for( i = 0; i < n; i++ ){
a.real = (double)i; a.imag = (double)i * 2.0;
b.real = (double)(n - i); b.imag = (double)i * 2.0;
}
zdotc( &c, &n, a, &inca, b, &incb );
printf( "The complex dot product is: ( %6.2f, %6.2f)\\n", a[1].real, a[1].imag );
system("PAUSE");
}

And I got following error message:

error LNK2019: unresolved external symbol _zdotc referenced in function _main

I think I did Additional dependencies for linkecorrect The following is what I have for this project:

mkl_intel_ilp64.lib
mkl_intel_thread.lib
mkl_core.lib
mkl_solver_ilp64.lib

What else do I



0 Kudos
4 Replies
mecej4
Honored Contributor III
311 Views
You are calling a Fortran-77 routine (zdotc) from a mix of C and C++ (#include ). Note that there are C interfaces to the MKL routines, as well.

The dot product is going to be in the variable c, not a[1]. Here is a modified version of zdotex.c:

[cpp]#include 
#include 

#define N 5

int main()
{
    MKL_INT n = N, inca = 1, incb = 1, i;
    MKL_Complex16 a, b, c;
    for( i = 0; i < n; i++ ){
        a.real = (double)i; a.imag = (double)i * 2.0;
        b.real = (double)(n - i); b.imag = (double)i * 2.0;
    }
    zdotc( &c, &n, a, &inca, b, &incb );
    printf( "The complex dot product is: ( %6.2f, %6.2f)n", c.real, c.imag );
}
[/cpp]
Compiling this, linking with the libraries that you listed, and running the .EXE file produced gave me the output

[cpp]The complex dot product is: (140.00, 20.00)[/cpp]
0 Kudos
Gennady_F_Intel
Moderator
311 Views
one comment on this topic. We can see that Yuzhuo used ilp64 interfaces. For this case, if you linked with ILP64 MKL libraries you need to add compiler option -DMKL_ILP64 for C-compilation.
We recomend to see more info into mkl's user's guide or into this forum, say here.
--Gennady
0 Kudos
Ying_H_Intel
Employee
311 Views

one more comments :).MSVC 2010 on 64bit Windows support both 32bit and 64bit application development.Ifyou'd like to link MKL ILP64 library,then your MSVC 2010 project configuration is supposed to be "x64", not the default "Win32".
In MSVS 2010* environment,please checkthe optionBuild=>Configuration Manager=> active platform.Select"X64" (if 64bit application).

Here is one genral KBabout MKL usage in VS1020 in Compiling and Linking MKL with Microsoft* Visual C/C++* .
and the on-line KB article Intel Math Kernel Library Link Line Advisorfor your reference,

Regards,
Ying

0 Kudos
Yuzhuo_Su
Beginner
311 Views
Sorry for not being replied to this thread any earlier. But THANK you all for your help. And Ying H's suggestion solves my problem.
0 Kudos
Reply