Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Compiling with g++

Jack_K_
Beginner
689 Views

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 Kudos
1 Solution
Ying_H_Intel
Employee
689 Views

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-ubun....  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

View solution in original post

5 Replies
VipinKumar_E_Intel
689 Views

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

 

Jack_K_
Beginner
689 Views

No, I don't thread with pthreads.

TimP
Black Belt
689 Views

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.

Ying_H_Intel
Employee
690 Views

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-ubun....  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

View solution in original post

Jack_K_
Beginner
689 Views

It works. Thank you everybody.

Reply