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

[Help] Example works with extention .c but fails with .cpp

Shi__Yue
Beginner
395 Views

Hi,

I have a big (n~100,000) complex matrix which I would like to diagonlize.

After googling extensively, I found the following link provides excellent example.

https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_zheev_row.c.htm

I was planning to be able have it work with my smaller problem before turning to a routine with parallel capabilities etc.

It compiles with "icc zheev.c -mkl -o test" on my machine and produced the correct output.

But when I tried to merge it into my code with a .cpp extension, it complains about

undefined reference to `zheev(char*, char*, int*, _dcomplex*, int*, double*, _dcomplex*, int*, double*, int*)'

After checking around, I found that this is presumably due to the extension that I have .cpp.

If I rename the zheev.c to zheev.cpp, "icc zheev.cpp -mkl -o test" complains also undefined reference to `zheev(char...

I know the problem may be too simple, please bear with me, this is my first day of using the routine.

Thanks,

Yue

0 Kudos
1 Solution
mecej4
Honored Contributor III
395 Views

To prevent C++ name decoration from being applied, surround the prototype declarations for MKL routines with exterm "C" {}; see http://www.cplusplus.com/forum/general/1143/ .

View solution in original post

0 Kudos
2 Replies
mecej4
Honored Contributor III
396 Views

To prevent C++ name decoration from being applied, surround the prototype declarations for MKL routines with exterm "C" {}; see http://www.cplusplus.com/forum/general/1143/ .

0 Kudos
Shi__Yue
Beginner
395 Views

Hi mecej4,

Thanks for the quick reply. It solved my problem.

Best regards,

Yue

0 Kudos
Reply