Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to link in the pthread library in CDT on linux?
How to link in the pthread library in CDT on linux? [message #187633] Fri, 16 March 2007 16:55 Go to next message
ying is currently offline yingFriend
Messages: 19
Registered: July 2009
Junior Member
How to link in the pthread library in CDT on linux?

I add 'pthread' in the libraries but I get this error when I compiles.

Invoking: GCC C++ Linker
g++ -o"sem" ./buffersem.o -lpthread
/usr/lib/gcc/i386-redhat-linux/4.1.0/../../../crt1.o: In function
`_start': undefined reference to `main'

Can you please tell me how to fix it?
Re: How to link in the pthread library in CDT on linux? [message #535291 is a reply to message #187633] Fri, 21 May 2010 22:05 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 10
Registered: November 2009
Junior Member
did you work this out? I'm looking for the same thing...
Re: How to link in the pthread library in CDT on linux? [message #536008 is a reply to message #187633] Wed, 26 May 2010 15:55 Go to previous messageGo to next message
James  is currently offline James Friend
Messages: 3
Registered: May 2010
Junior Member
You need to give the -pthread command line option to g++, not -lpthread

If you are using the automatic build (Generate Makefiles automatically) then:
Open project properties -> C/C++ Build -> Settings -> Tool Settings tab -> GCC C++ Linker -> Miscellaneous

put "-pthread" without the quotes in the top box (Linker flags)

Hope that helps,
James.

screen shot: http://www.schwan.us/eclipse/Screenshot.png

Re: How to link in the pthread library in CDT on linux? [message #1428703 is a reply to message #187633] Mon, 22 September 2014 07:59 Go to previous messageGo to next message
Son vx is currently offline Son vxFriend
Messages: 2
Registered: September 2014
Junior Member
This works for me:

Project properties -> in C/C++ Build -> Settings -> Tool Settings tab -> In GCC C Linker -> Libraries -> add "pthread" there and enjoy.

This is the same in your command line when you put -l pthread Smile.

Hope this help.

  • Attachment: pthread.png
    (Size: 64.93KB, Downloaded 1266 times)
Re: How to link in the pthread library in CDT on linux? [message #1428706 is a reply to message #187633] Mon, 22 September 2014 08:00 Go to previous message
Son vx is currently offline Son vxFriend
Messages: 2
Registered: September 2014
Junior Member
This works for me. See the pic.
  • Attachment: pthread.png
    (Size: 64.93KB, Downloaded 2746 times)
Previous Topic:cdt debug can't find source files
Next Topic:Running Eclipse in Windows.. Is it even possible?
Goto Forum:
  


Current Time: Thu Mar 28 13:38:33 GMT 2024

Powered by FUDForum. Page generated in 0.03875 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top