【问题标题】:gcc difference between -pthread and -pthreads?gcc -pthread和-pthreads之间的区别?
【发布时间】:2023-08-31 21:24:02
【问题描述】:

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

【问题讨论】:

  • 不是编译器的函数,是库的实现函数。

标签: gcc compiler-construction pthreads portability


【解决方案1】:

Solaris -pthreads 和 Linux -pthread 选项做相同的事情。显然,gcc-4.x 系列也接受 -pthread 用于 Solaris。

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

【讨论】:

    最近更新 更多