Pthread Link 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_create' ubuntu Discuss the workings and policies of this site About Us Learn
Cmake Pthread
more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us ubuntu install pthread 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
Undefined Reference To `pthread_create' Cmake
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' c++ 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 this site About Us Learn more about Stack
Undefined Reference To Pthread_create Code Blocks
Overflow the company Business Learn more about hiring developers or posting ads with us
Undefined Reference To Pthread_create' Makefile
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a undefined reference to `pthread_create' c++11 community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up linking pthread library issue up vote 2 down vote favorite Am facing a problem that http://stackoverflow.com/questions/6332410/compile-link-error-using-pthread may be slightly complicated to explain and understand as giving the entire picture would be too big and difficult. Please excuse me for it. Consider the following Makefile: all: clients.so simulator backup LD_PRELOAD=/home/Juggler/client/clients.so ./simulator backup: backup.c libclient.a gcc backup.c -o backup -L /home/Juggler/client -L. -lclient -ldl simulator: simulator.c libclient.a gcc -g simulator.c -o simulator -L /home/Juggler/client -L. -lclient -ldl -pthread libclient.a: libclient.o client.o ar rcs libclient.a libclient.o client.o libclient.o:libclient.c gcc -c http://stackoverflow.com/questions/7419163/linking-pthread-library-issue libclient.c -o libclient.o -pthread clients.so: client.o client_invoke.o ld -shared -o clients.so client_invoke.o client.o -ldl client_invoke.o: client_invoke.c gcc -Wall -fPIC -DPIC -c -g client_invoke.c client.o: client.c gcc -Wall -fPIC -DPIC -c -g client.c -ldl -pthread We call function written in client.c from libclient.c and these functions in client.c make call to pthread_key_create(), pthread_setspecific..etc. Threads are created by simulator.c and theses threads access functions written in he other files. On doing make...Errors like the following appear. /home/Juggler/client/libclient.a(client.o):In function 'setup_connection': /home/Juggler/client/client.c:35: undefined reference to 'pthread_setspecific' pthread.h has been included in both client.c and libclient.c Would be grateful for anypointers . I understand information is very less... Thanks c linux makefile pthreads share|improve this question edited Sep 14 '11 at 16:03 Bertrand Marron 12.1k63371 asked Sep 14 '11 at 15:44 Lipika Deka 1,22832347 add a comment| 1 Answer 1 active oldest votes up vote 8 down vote accepted On linux, pthread functions live in the libpthread library. So you have to link to that. The proper way, when using pthreads, is to compile and link using the -pthread , which, among other things, will link in the pthread library. You have the -pthread flag for some of your executables, but not for others, and not for your clients.so library, so add the flag where requ
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code https://ubuntuforums.org/showthread.php?t=1525607 of Conduct Ubuntu Wiki Community Wiki Other Support Launchpad Answers Ubuntu IRC Support AskUbuntu Official Documentation User Documentation Social Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu http://askubuntu.com/questions/420722/how-to-compile-a-c-program-that-uses-pthread-h PPAs: Ubuntu Web Upd8: Ubuntu OMG! Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO login Advanced Search Forum The Ubuntu Forum Community Ubuntu Specialised Support undefined reference Development & Programming Programming Talk undefined reference to 'pthread_create' from linker Having an Issue With Posting ? Do you want to help us debug the posting issues ? < is the place to report it, thanks ! Results 1 to 7 of 7 Thread: undefined reference to 'pthread_create' from linker Thread Tools Show Printable Version undefined reference to Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode July 7th, 2010 #1 CrazyDavy View Profile View Forum Posts Private Message First Cup of Ubuntu Join Date Jul 2010 Location Texas Beans 6 DistroUbuntu 9.10 Karmic Koala undefined reference to 'pthread_create' from linker I am having trouble linking the pthread library. Using Code::Blocks 8.02 I have -lpthread -lm as options for the GNU GCC compiler. Build Log ------------------------------------------------------------ Compiling: main.c Compiling: matrix.c Compiling: newmalloc.c Linking console executable: bin/Release/optimizer-4 obj/Release/main.o: In function `main': main.c.text+0x132): undefined reference to `pthread_attr_setstacksize' main.c.text+0x224): undefined reference to `pthread_create' main.c.text+0x35b): undefined reference to `pthread_join' collect2: ld returned 1 exit status Process terminated with status 1 (0 minutes, 1 seconds) 3 errors ------------------------------------------------------------- library search: dlyon@dlyon-desktop2:~$ ls /usr/lib |grep pthread libgpgme-pthread.so.11 libgpgme-pthread.so.11.7.0 libpthread.a libpthread_nonshared.a libpthread.so dlyon@dlyon-desktop2:~$ ------------------------------------------------------------- Any ideas would be greatly appreciated! Thanks! Adv Reply July 7th, 2010 #2 dwhitney67 View Profile View Forum Posts Private Message Tolerant of Ubuntu Join Date
communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start 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 this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top how to compile a c program that uses pthread.h? up vote 4 down vote favorite 1 I'm a beginner and I'm new to Ubuntu. I just installed it and want to run a C program. I have no idea what platform to use or where to write the code. I need to use pthread.h header file in the program. Can anyone help me? c share|improve this question edited Feb 14 '14 at 7:53 OrangeTux 2,88581949 asked Feb 14 '14 at 6:47 user248075 27112 possible duplicate of How to compile c & c++ programs? –Elder Geek Feb 19 '15 at 15:22 add a comment| 4 Answers 4 active oldest votes up vote 8 down vote Use: gcc MyProgram.c -o MyProgram -lpthread and dont forget to include the POSIX library in your code. It will compile your code. share|improve this answer edited Oct 6 '14 at 17:13 muru 69.5k12127177 answered Apr 5 '14 at 9:16 Parthiv Shah 10619 2 by default GCC does not include the pthread library. so you have to include the library using lpthread argument. –Parthiv Shah Apr 5 '14 at 9:30 Also note that in gcc-4.8 there is not -lpthread argument in man gcc. But there is a -pthread argument. Both work fine on Ubuntu 14.04 with gcc-4.8. –Elijah Lynn Aug 19 at 0:07 add a comment| up vote 0 down vote First thing you'll need in Ubuntu to compile C/C++ programs is installing GCC (Gnu Compiler Collection) which is part of build-essential package , do that by running: sudo apt-get install build-essential Then you can test if you have it installed by running gcc. If you you see error like Fatal err