Have you come across a situation where a C/C++ project that uses Pthread API fails to compile via the Eclipse IDE?
If your answer to the above question is ‘YES’, then this post is for you.
The CDT plugin in the Eclipse IDE is not configured to add the -pthread
argument when the user tries to compile a C/C++ project. Please follow the steps listed below to successfully compile a C/C++ project which uses Pthread library in Eclipse.
- Open Eclipse (it is assumed that CDT plugin is installed).
- On the menu bar, choose
Projects->Properties
. - From the bar on the left, choose
c/c++ build –> GCC C Compiler –> Miscellaneous
. - Add the
-pthread
argument into the beginning of theOther Flags
. - Choose
c/c++ build–>Settings->GCC C Linker->Libraries
and include thepthread
library into the other libraries. - Click
Apply
and rebuild the project.Pthreads
should work now.
THAAAAAAAAAAAAAAAAAAAAAAANKS ALOT! God Bless You! 😀
I’m getting the next error on compilation time:
cannot find -lpthread
on Eclipse, please help me 😦
same here. It does not work
I am university student in the Brazil.
Your initiative has very good.
Thanks !!!
God blesssssss!!!! thanks a lot, saved my life =)
thanks a lot,,
it works,.
thanks thanks thanks
regards
OH YOU BEAUTIFUL PERSON, IT WORKS, OH IT WORKS, OH GOOD GOD THANK YOU.
Thank you!
Do you guys know how to debug the pthreads in eclipse?
I call pthread_create and I know the code is running as it’s outputting properly; however, I need to debug as I believe there are some errors in it. Any idea?
thank you very very much! 🙂