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

Compiling with g++

Jack_K_
初学者
4,304 次查看

How can I compile my program with mkl and g++?

I already tried the mkl line advisor, but I got the "pthread_mutex_trylock" message.

How`s it going ?

Thanks.

0 项奖励
1 解答
Ying_H_Intel
主持人
4,304 次查看

Hi Jack,

Are you working on Ubuntu system?

It looks similiar problem as  http://software.intel.com/en-us/forums/topic/501970#comment-1779725 and the one in http://software.intel.com/en-us/articles/symbol-lookup-error-when-linking-intel-mkl-with-gcc-on-ubuntu.  Some ubuntu and GCC have the issue, some have not.

You may try to add the compiler option : -Wl,--no-as-needed.   for example

g++ -Wall -o test.exe test.cpp -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -ldl -lpthread -lm

Best Regards,

Ying

在原帖中查看解决方案

0 项奖励
5 回复数
VipinKumar_E_Intel
4,304 次查看

What is your linkline?

For intel64, lp64 interface, it is something like this.

 -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_gnu_thread.a -Wl,--end-group -ldl -lpthread -lm

Have you threaded your program with pthreads?

--Vipin

 

0 项奖励
Jack_K_
初学者
4,304 次查看

No, I don't thread with pthreads.

0 项奖励
TimP
名誉分销商 III
4,304 次查看

The point is, somewhere in your build you are calling a pthread function, e.g. by using OpenMP in your own code or by linking an mkl_thread library.  You will need either to remove the pthread function usage or link properly to support it.

0 项奖励
Ying_H_Intel
主持人
4,305 次查看

Hi Jack,

Are you working on Ubuntu system?

It looks similiar problem as  http://software.intel.com/en-us/forums/topic/501970#comment-1779725 and the one in http://software.intel.com/en-us/articles/symbol-lookup-error-when-linking-intel-mkl-with-gcc-on-ubuntu.  Some ubuntu and GCC have the issue, some have not.

You may try to add the compiler option : -Wl,--no-as-needed.   for example

g++ -Wall -o test.exe test.cpp -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -ldl -lpthread -lm

Best Regards,

Ying

0 项奖励
Jack_K_
初学者
4,304 次查看

It works. Thank you everybody.

0 项奖励
回复