Pthread Linker Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta undefined reference to pthread Discuss the workings and policies of this site About Us Learn
Gcc Pthread Option
more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us how to install pthread library in ubuntu Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like
Gcc Pthread Compile
you, helping each other. Join them; it only takes a minute: Sign up compile/link error using pthread up vote 3 down vote favorite I try to make a little program that sorts an array using threads but I can't get it to compile with the thread support. Error: sortieren.c:(.text+0xd7): undefined reference to `ptread_create' I used a make undefined reference to `pthread_create' cmake file for easy compiling but also on command line I can't get it to work. Basic code: #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Gcc Pthread Vs Lpthread
this site About Us Learn more about Stack Overflow the company Business
Undefined Reference To Pthread_create' C++
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask undefined reference to pthread_create' makefile Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/6332410/compile-link-error-using-pthread up undefined reference to `pthread_key_create' (linker error) up vote 7 down vote favorite I have downloaded gtest 1.7.0 sources from here: https://code.google.com/p/googletest/downloads/list and build the gtest .a files (lib files) on ubuntu 13.10: Linux ubuntu 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux and the resulting lib is called: libgtest.a. In my main.cpp file Have: #include
Things LocationTech Long-Term Support PolarSys Science OpenMDM More Community Marketplace Events Planet Eclipse Newsletter Videos Participate Report a Bug Forums Mailing Lists Wiki IRC How to Contribute Working https://www.eclipse.org/forums/index.php/t/59314/ Groups Automotive Internet of Things LocationTech Long-Term Support PolarSys Science OpenMDM Toggle navigation Home Projects Forums Eclipse Community Forums Forum Search: Search Help Register Login http://blog.asteriosk.gr/2009/02/15/adding-pthread-to-eclipse-for-using-posix-threads/ Home Home» Language IDEs» C / C++ IDE (CDT)» How to link in the pthread library in CDT on linux? Show: Today's Messages :: Show Polls :: Message Navigator undefined reference How to link in the pthread library in CDT on linux? [message #187633] Fri, 16 March 2007 16:55 yingMessages: 19Registered: 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 undefined reference to `_start': undefined reference to `main' Can you please tell me how to fix it? Report message to a moderator 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 Missing name Mising nameMessages: 10Registered: November 2009 Junior Member did you work this out? I'm looking for the same thing... Report message to a moderator 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 James Messages: 3Registered: 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: Report message to a moderator Re: How t
not configured to put the -pthread argument in the gcc compilation. To solve this, go to the Menu: Project -> Properties From the bar on the left: c/c++ build -> GCC C Compiler -> Miscellaneous Add the "-pthread" argument into the beginning of the “Other Flags” Also go to: 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. There are 176 comments in this article: 23/02/2009ahmet say: thanks 10/04/2009rajend say: this one helped me too… thanks a lot 4/07/2009fork() a child say: it helped me too… thanks! 28/10/2009alex say: +1 21/11/2009nuno say: thanks a lot:D 6/01/2010vinod say: Thanks dude, yu rock… V… 23/02/2010aaron say: Thank you. 5/03/2010alex say: thanks a lot.. 15/04/2010dahdash say: tnx ;) 17/10/2010donat3llo say: thanks a bunch bro, works like a charm for me. 21/11/2010david say: thank you very mutch god bless you 23/11/2010Gluko say: Thanks!!! very helpful 23/02/2011Fred say: Thanks! 29/04/2011Dolcezeus say: don't work for me.. i have an linker error the option is present on compiler but not on Linker console outpt.. please help me, if i compile manually the program work fine, but in eclipse i can't buid it. 1/05/2011desufag say: Thank you, really helped. 9/06/2011Abraham say: Does anyone know how to debug pthreads in eclipse? I tried using breakpoints but I never hit them; however the console output tells me the code is indeed running and outputting correctly. 14/06/2011Roy say: Thank you ..really helped 18/09/2011cash say: thank a lot :) 2/10/2011some dude say: awesome simple fix. thanks 26/10/2011Cem say: thanks my brother, it has worked but i didnt understand why we had to do this configuration 6/11/2011Hashim Ali say: Hello! Thanks for the post. I have one question, What do you think if I have requirement of non-blocking thread kind of functionality but not using threads? Many thanks for help. 23/11/