C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 25th, 2006, 09:21 PM
dillidamunda dillidamunda is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 9 dillidamunda User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 36 sec
Reputation Power: 0
Undefined reference to `pthread_create'

i made a program the error while compilation comes like:

undefined reference to `pthread_create'

pls suggest.

Last edited by dillidamunda : September 25th, 2006 at 09:42 PM. Reason: mismatch

Reply With Quote
  #2  
Old September 25th, 2006, 10:44 PM
L7Sqr L7Sqr is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: Constant Limbo
Posts: 591 L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 14 h 1 m 6 sec
Reputation Power: 100
Send a message via AIM to L7Sqr
Depends on the system, but try:

#include <pthread.h>

And when compiling:

gcc ... -pthread ...
__________________
-- I'll provide you with reference points; if they dont work, refer to something else.

If you process text, this might make your life a little easier.

Reply With Quote
  #3  
Old September 28th, 2006, 02:21 PM
c4all c4all is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: CA,USA
Posts: 179 c4all User rank is Lance Corporal (50 - 100 Reputation Level)c4all User rank is Lance Corporal (50 - 100 Reputation Level)c4all User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 4 Days 9 h 3 m 45 sec
Reputation Power: 4
Quote:
Originally Posted by L7Sqr
Depends on the system, but try:

#include <pthread.h>

And when compiling:

gcc ... -pthread ...


I believe it should be
Quote:
gcc ... -lpthread ..

Reply With Quote
  #4  
Old September 28th, 2006, 10:34 PM
L7Sqr L7Sqr is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: Constant Limbo
Posts: 591 L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level)L7Sqr User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 14 h 1 m 6 sec
Reputation Power: 100
Send a message via AIM to L7Sqr
Code:
tux64-05:0:~/tmp > gcc t.c
/tmp/ccKRLyw2.o: In function `main':
t.c:(.text+0x45): undefined reference to `pthread_create'
collect2: ld returned 1 exit status
tux64-05:0:~/tmp > gcc -pthread t.c
tux64-05:0:~/tmp >


Either way.

from man gcc
Code:

       -pthread
           Adds support for multithreading with the pthreads library.  This
           option sets flags for both the preprocessor and linker.

Reply With Quote
  #5  
Old May 7th, 2008, 07:45 AM
bob81 bob81 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 1 bob81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 31 sec
Reputation Power: 0
This might also be useful.

This is also platform dependent. you can use -pthread and -lpthread both. The only difference is that:
Compiler/Platform :PGI Linux Command is: pgcc -lpthread
Compiler/Platform :GNU Linux, AIX Command is: gcc -pthread

Cheers!
Comments on this post
L7Sqr disagrees: You saved the day. And just in time too!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Undefined reference to `pthread_create'


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway