Can't find -lpthread?

I am new to C programming.

I tried to use the pthread API to write some parallel program.

I downloaded the Eclipse IDE for C / C ++, MinGW developers. I put the whole library header files in the appropriate location of the MinGW file.

When I tried to create a project, there is always a "can't find -lpthread" error, what happened? I added "-pthread" to the GCC compiler.

I searched a lot on Google, but it seems I don't have the same problem as me.

+3
source share
4 answers

, MinGW pthread library, ! , , MinGW script lpthread . :

MinGW, MinGW, " " , "mingw32-pthreads-w32" .

+5

Eclipse IDE C/++, MinGW.

MingGW Windows API. API Windows PThreads.

PThreads Win32, PThreads Windows MinGW.

+2

Eclipse -pthread gcc. , : ? 1.Project →

From the left pane: view source? 1.c / C ++ build -> GCC C Compiler -> Miscellaneous

Add the argument "-pthread" to the beginning of the "Other flags". Also follow the link: view source? 1.c / C ++ build → Settings → GCC C Linker → Libraries

And include the pthread library in other libraries. Click Apply and rebuild the project. Pthreads should work now.

+1
source

See the question at mingw.org . I ended up adding 'C:/cygwin/lib'to the settings for "library search path (-L)" in properties >> c/c++ build >> settings >> MinGW C Linker >> Libraries.

0
source

All Articles