Tudor Versoiu Tudor Versoiu - 1 year ago 327
C++ Question

MinGW 5.3.0-2 not working

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

Answer Source

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

like this

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download