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

Compiling with g++

Jack_K_
Beginner
2,669 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
2,669 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-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

View solution in original post

0 Kudos
5 Replies
VipinKumar_E_Intel
2,669 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

 

0 Kudos
Jack_K_
Beginner
2,669 Views

No, I don't thread with pthreads.

0 Kudos
TimP
Honored Contributor III
2,669 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.

0 Kudos
Ying_H_Intel
Employee
2,670 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-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 Kudos
Jack_K_
Beginner
2,669 Views

It works. Thank you everybody.

0 Kudos
Reply