3

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

Community
  • 1
  • 1
Tudor Versoiu
  • 122
  • 2
  • 8

2 Answers2

2

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

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
1

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

  • Thank you for the answer! I had the nosteup version of codeblocks and MinGW in the C drive, also added "C:\MinGW\bin" to the path variable. . Everything was set up correctly. Everything was working fine... Until i updated MinGW to the newest version and at that point i got the error. Then i got an older version of MinGW and this one works. I think that somehow MinGW 5.0.3-2 is bugged :) – Tudor Versoiu Aug 28 '16 at 17:07
  • @TudorVersoiu: It's not "bugged"; it works for everyone else. Read the information given to you here. – Lightness Races in Orbit Aug 28 '16 at 18:36