Invoking gcc -pthread under ExtUtils::MakeMaker

南笙酒味 提交于 2019-12-11 01:22:25

问题


What's the right way to specify compilation and linking with -pthread (not -lpthread) in a Makefile.PL?

It's my understanding that gcc ought to be invoked with -pthread when building against pthreads, as this flag expands to the correct platform-specific flags for both compilation and linking.

I started with:

use Config;
my %mm = ( NAME => 'Local::Example::Pthreaded', ...);
...
if ($Config{ccname} eq 'gcc') {
  $mm{DEFINE} = join(' ', '-pthread', $mm{DEFINE});   # ??? in the right place?
  $mm{LIBS}   = ['-pthread'];                         # XXX ignored!

}
WriteMakefile(%mm);

However, I'm not sure that the DEFINE usage puts -pthread in the right place. (User DEFINEs appears at the end of the compilation command.) Moreover, the LIBS argument is ignored because it doesn't look like a typical -l/-L linker argument: "Unrecognized argument in LIBS ignored: '-pthread'".

来源:https://stackoverflow.com/questions/15929739/invoking-gcc-pthread-under-extutilsmakemaker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!