The link line provided by MKL link line advisor(https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor) for linking static sequential libraries is:
-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm
and -I$(MKLROOT)/include
My question is, why -lpthread library required to link a sequential library?
Link Copied
Hi San,
Thank you for the post. Right, it seem the -lpthread are not needed by sequential linkage. I will check it with internal owner and fix the problem if possible.
Thanks
Ying
Hi San,
I get feedback from our team, as quite often users who use sequential linking of MKL exploit own threading in their applications. To be thread safe in that case MKL has to use TLS functionality of lpthread. Thus we require lphtread even for sequential linking. So it seems better to keep it there. and user can remove manually if it is not needed.
Best Regards,
Ying
For more complete information about compiler optimizations, see our Optimization Notice.