13

I am currently trying to install Eclipse for making C++ programs.

I've run into an issue when compiling the premade default hello world program.

The console shows this error:

c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpthread

I am not using the library in my program at all.

Any ideas on how to fix this?

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
Namr2000
  • 133
  • 1
  • 1
  • 5

4 Answers4

21

Just run and open MinGW Installation Manager, which should be pre-installed with MinGW, select "All Packages" on the left panel, and on the right panel, search for "mingw32-pthreads-w32" packages and install them.

Restart Eclipse, rebuild the project and run it. It should now work.

Kupar Buhroy
  • 346
  • 3
  • 8
3

I had the same problem even with those packages installed. I had to go to mingw\lib and copy the file libpthreadGC-3.a and rename it to libpthread.a and the file libpthreadGC-3.dll.a rename it to libpthread.dll.a

After that it works!

0

After installing MinGw mingw-gcc-g++, reopen Eclipse, then clear errors. Once all the errors are cleared, try rebuilding your project.

0

If you also have cygwin installed ... see the question on mingw.org. I ended up with adding 'C:/cygwin/lib' to the settings for the "Library search path (-L)" at properties >> c/c++ build >> settings >> MinGW C Linker >> Libraries.

minghua
  • 5,981
  • 6
  • 45
  • 71