问题 gp -pthread和-pthreads之间的区别?


我有一个pthreads程序。我必须在Linux中使用gcc -pthread(-pthreads是无法识别的选项)和Sun中的gcc -pthreads(-pthread是无法识别的选项)进行编译。为什么不同,因为它是相同的编译器?但是,-lpthread适用于两者,但我听说这并不总是足够的。


2664
2017-12-09 23:30


起源

它不是编译器的功能,它是库实现的功能。 - i_am_jorf


答案:


Solaris -pthreads 和Linux -pthread 选项做同等的事情。显然, gcc-4.x 系列接受 -pthread 对于Solaris也是如此。

你确实想要 -pthread/-pthreads 编译时的选项,因为它在预处理器和链接器中添加了多线程支持。


12
2017-12-11 05:24