问题
I get a bizzare error after upgrading to MinGW 5.3.0-2(actual version)
I checked everything because It's the 5th time i reinstall it and thought it would help
Code::Blocks outputs this:
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))
Note: if I check the -std=c++11 OR -std=c++14 flags i get output like here: Click me
Is it a problem with the last version of MinGW? If so where can I get the last working version? Or is anything in my computer messed up? I would like to keep this version if its possible to fix it but its getting me crazy
回答1:
You haven't installed the Posix Threads (pthread) library, so the linker
can't find it. The particular Windows GCC packager that you have chosen doesn't
install it by default.
Start the MinGW Installation Manager and navigate All Packages -> MinGW
-> MinGW Standard Libraries. In the Standard Libraries presented, select
mingw32-pthreads-w32 dev. Then from the menubar select Installation -> Apply Changes
and proceed. Make it look like
Newer Windows GCC packagers, e.g. mingw-w64 or TDM-GCC, will install pthreads by default and provide 64- as well as 32-bit compilers. mingw-w64 in addition offers more up-to-date versions of GCC (currently 6.2, which is the latest GCC release).
回答2:
If you use codeblocks-16.01-nosetup version or the earlier similar version then you need to install MinGW in home directory of C drive (C:\MinGW) and you have to add "C:\MinGW\bin" in the system variable called "Path". However, I would recommend to use "codeblocks-16.01mingw-setup.exe" version of codeblocks. This has a preloaded MinGW latest version. you can get it from here: https://sourceforge.net/projects/codeblocks/files/Binaries/16.01/Windows/codeblocks-16.01mingw-setup.exe/download
来源:https://stackoverflow.com/questions/39168007/mingw-5-3-0-2-not-working