为什么 C++ "Hello World" 在 Eclipse Mars 中需要 pthread(缺少)?

Why does C++ "Hello World" require pthread (which is missing) in Eclipse Mars?

我已经 运行 Eclipse Juno 和 MinGW 4.6.2 很长时间了,但我需要完整的 C++11 支持,所以我升级到 Eclipse Mars 并在不同的环境中安装了 MinGW 4.9.3目录。

在火星上,link运行任何可执行文件 - 即使在 C++ Hello World 项目中 - 也会导致 "C:\MinGW_4_9_4\bin...\ld.exe: cannot find -lpthread."

4.6.2 目录(用于 Juno)包含 pthread,但 4.9.3 目录(用于 Mars)没有。

Mars 为什么以及如何尝试 link pthread? (我可以关掉它吗?)

我无法确定是否可以 link w/o pthread,但我注意到在我安装(并重新安装 w/maxmium 选项后 pthread 不存在) MinGW 4.9.3。可能是安装程序错误?

2008年,MinGW说"Use sourceware.org's pthreads-win32 at your own risk"。我现在看到 mingw-pthreads-win32 是 MinGW Installation Manager Setup Tool (mingw-get.exe) 中的一个标准库。我对 MinGW 对 Win-32 的纯粹主义态度感到满意,所以我安装了这个库。万岁 - 问题解决了! ld.exe 现在可以找到 -lpthread。

您可以在左侧面板 "All Packages/MinGW/MinGW Libraries/MinGW Standard Libraries" 下的 MinGW 安装管理器设置工具中找到该包;它是右窗格中的 "mingw-pthreads-win32" 包 ("dev" class)。