I am new to C programming.
I was trying to use the pthread API to write some concurrent program.
I downloaded eclipse IDE for C/C++ Developers, MinGW. I have put all the library, header files into the corresponding location of the MinGW file.
When I tried to build the project, there is always an error "cannot find -lpthread", what happened? I have added the "-pthread" to the GCC compiler.
I have searched a lot in Google but seems no one have similar problem as me.
The answer to this question by someone who is also missing MinGW pthread library should help you out! Essentially the issue is that the MinGW installer script might not download the lpthread library upon installation. Quoted from link:
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.
I downloaded eclipse IDE for C/C++ Developers, MinGW.
MingGW uses the Windows API. The Windows API does not provide PThreads.
You need to install PThreads for Win32 to have PThreads available under Windows, and with this available under MinGW.
Eclipse is not configured to put the -pthread argument in the gcc compilation. To solve this, go to the Menu: view sourceprint? 1.Project -> Properties
From the bar on the left: view sourceprint? 1.c/c++ build -> GCC C Compiler -> Miscellaneous
Add the “-pthread” argument into the beginning of the “Other Flags” Also go to: view sourceprint? 1.c/c++ build -> Settings -> GCC C Linker -> Libraries
And include the “pthread”library into the other libraries. Click Apply and rebuild the project. Pthreads must work now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With