12
votes

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?

4
Have you tried running the program directly from the command line?Christian Dean
And are you using any libraries at all?Christian Dean

4 Answers

16
votes

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.

3
votes

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
votes

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

0
votes

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.