我有一个 pthreads 程序。我必须使用 Linux 中的 gcc -pthread(-pthreads 是无法识别的选项)和 Sun 中的 gcc -pthreads(-pthread 是无法识别的选项)编译它。为什么不同,因为它是相同的编译器?但是,-lpthread 对两者都有效,但我听说这并不总是足够的。
最佳答案
Solaris -pthreads
和 Linux -pthread
选项做等效的事情。显然,gcc-4.x
系列接受-pthread
也适用于 Solaris。
您确实想要 -pthread
/-pthreads
编译时的选项,因为它在预处理器和链接器中添加了多线程支持。
关于gcc -pthread 和 -pthreads 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1877702/