我有一个使用pthread的程序。在Linux中,我必须使用gcc -pthread编译它(-pthreads是未被识别的选项),而在Sun中,我必须使用gcc -pthreads编译它(-pthread是未被识别的选项)。为什么会有这种差异呢?因为这是同样的编译器吗?然而,在两个平台上都可以使用-lpthread,但我听说这并不总是足够的。
我有一个使用pthread的程序。在Linux中,我必须使用gcc -pthread编译它(-pthreads是未被识别的选项),而在Sun中,我必须使用gcc -pthreads编译它(-pthread是未被识别的选项)。为什么会有这种差异呢?因为这是同样的编译器吗?然而,在两个平台上都可以使用-lpthread,但我听说这并不总是足够的。
-pthreads
和Linux的-pthread
选项具有相同的功能。显然,gcc-4.x
系列也接受将-pthread
用于Solaris。-pthread
/-pthreads
选项,因为它会在预处理器和链接器中添加多线程支持。