LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2010, 10:55 PM   #1
CrazyDave
LQ Newbie
 
Registered: Jul 2010
Location: Katy, Texas
Distribution: Ubuntu 10.04
Posts: 1

Rep: Reputation: 0
Angry undefined reference to 'pthread_create' from linker


I am having trouble linking the pthread library.

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!
 
Old 07-06-2010, 11:30 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
with out knowing what you are building we can not even guess
something is missing in some code ?? as to what ??
without seeing it ....
 
Old 07-06-2010, 11:55 PM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
From man gcc (search for -llibrary in there)
Quote:
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.
Maybe that's the problem?
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"undefined reference"linker error for static field w/ C++ astorm Programming 5 08-27-2008 03:00 AM
linker issue - undefined reference error asif.kalim Programming 3 04-19-2008 05:18 AM
Linker does not catch undefined functions when building GStreamer plugin asaeed Linux - Software 0 04-07-2008 05:11 PM
undefined reference vkmgeek Programming 1 05-11-2006 06:37 AM
Undefined Reference Linker Problem DWo Programming 1 03-11-2006 04:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration