Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Erasmo_Coletti
Beginner
60 Views

Get an example function working

Hi,

I just loaded the Intel MKL library andI am trying to make an example work in C++. I copied the example from the web. The code I copied is as below:

//Example 2: Calling a Complex BLAS Level 1 Function from C++

#include "mkl.h"
typedef struct{ double re; double im; } complex16;

extern "C" void zdotc (complex16*, int *, complex16 *, int *, complex16 *, int *);

#define N 5

void test1()

{

int n, inca = 1, incb = 1, i;

complex16 a, b, c;

n = N;

for( i = 0; i < n; i++ ){

a.re = (double)i; a.im = (double)i * 2.0;

b.re = (double)(n - i); b.im = (double)i * 2.0;

}

zdotc(&c, &n, a, &inca, b, &incb );

printf( "The complex dot product is: ( %6.2f, %6.2f) ", c.re, c.im );

}

I get as an error : second C linkage of overloaded function 'zdotc' not allowed

Can somebody tell me/help me about why the above is not working?

Thank you for your help.

E.

0 Kudos
3 Replies
Todd_R_Intel
Employee
60 Views

Could it be because the MKL header file already has the zdotc prototype and you define it again (slightly differently) in your example source? If you look in mkl_blas.h you'll see the following prototype:

void zdotc(MKL_Complex16 *pres, const MKL_INT *n, const MKL_Complex16 *x, const MKL_INT *incx, const MKL_Complex16 *y, const MKL_INT *incy);

Todd
Erasmo_Coletti
Beginner
60 Views

Todd,

Thank u for ur response.
I could not get the above code to work, by the way its in Visual Studio 2008, I then decided to change a bit and try the below one:

#include "mkl.h"
extern "C" float sdot(const MKL_INT *n, const float *x, const MKL_INT *incx, const float *y, const MKL_INT *incy);

#define N 5

void test1()

{

MKL_INT n, inca = 1, incb = 1, i;

const float a = {1, 2, 3, 4, 5}, b = {6, 7, 8, 9, 10};

n = N;

sdot(&n, a, &inca, b, &incb);
printf( "The dot product is: ( %6.2f, %6.2f) ", n );

}

The error msg I get is:

mkl_intel_c.lib(_sdot.obj) : error LNK2019: unresolved external symbol _mkl_blas_sdot referenced in function _sdot

1>Release/XLStats.xll : fatal error LNK1120: 1 unresolved externals

Does anyboduy have an idea about how to fix it?

Thank you.

Gennady_F_Intel
Moderator
60 Views

please add the required libraries to the Configuration Properties:
Linker\Input\Additional Dependencies:mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib
as well add the path to the directory
Linker\General\Additional Libraries Directory:\ia32\lib\
where , as an example ==C:\Apps\Intel\MKL\10.2.4\ia32\lib\
--Gennady
Reply