MinGW 5.3.0-2无法正常工作

时间:2016-08-26 13:53:17

标签: c++ windows c++11 mingw codeblocks

升级到MinGW 5.3.0-2(实际版本)

后出现严重错误

I checked everything because It's the 5th time i reinstall it and thought it would help

Code :: Blocks输出:

mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\Tudor\Documents\C++\test\main.cpp -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\test.exe obj\Debug\main.o   
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpthread
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

注意:如果我检查-std = c ++ 11 OR -std = c ++ 14标志,我会得到如下输出:Click me

MinGW的最新版本有问题吗?如果是这样我在哪里可以获得最后一个工作版本?或者我的电脑中有什么东西搞砸了?我想保留这个版本,如果它有可能修复它,但它让我疯了

2 个答案:

答案 0 :(得分:1)

如果您使用codeblocks-16.01-nosetup版本或更早的类似版本,那么您需要在C盘的主目录(C:\ MinGW)中安装MinGW,并且您必须在其中添加“C:\ MinGW \ bin”系统变量称为“路径”。 但是,我建议使用“codeblocks-16.01mingw-setup.exe”版本的代码块。这有预装的MinGW最新版本。你可以从这里得到它:https://sourceforge.net/projects/codeblocks/files/Binaries/16.01/Windows/codeblocks-16.01mingw-setup.exe/download

答案 1 :(得分:1)

你还没有安装Posix线程(g.setColor( getBackground() ); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor( getForeground() ); g.drawRect(...); )库,所以链接器 找不到它。您选择的特定Windows GCC打包程序不具备此功能 默认情况下安装它。

启动MinGW Installation Manager并导航所有包 - >的的MinGW - > MinGW标准库。在显示的标准库中,选择 pthread。然后从菜单栏选择安装 - > 应用更改 然后继续看起来像

like this

较新的Windows GCC打包程序,例如mingw-w64TDM-GCC,将默认安装pthreads 提供64位以及32位编译器。 mingw-w64另外提供更新 GCC的版本(目前为6.2,这是最新的GCC版本)。