LinuxQuestions.org
Help answer threads with 0 replies.
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 02-08-2005, 01:32 AM   #1
JanusPaul
Member
 
Registered: Nov 2004
Location: Houston, Texas
Distribution: Ubuntu, Debian, Solaris, Free BSD
Posts: 82

Rep: Reputation: 15
Pthread


I have #include <pthread.h> in my header file.
And yet I'm getting an undefined symbol: pthread_create error. Any suggestions?
 
Old 02-08-2005, 02:04 AM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
What does the rest of the thread-code look like?

EDIT: If you are compiling with gcc/g++ make sure you use the -lphtread to link it with the correct lib. Or do as Marius mentioned if you use KDevelop.

Last edited by Ephracis; 02-08-2005 at 02:21 AM.
 
Old 02-08-2005, 02:09 AM   #3
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276

Rep: Reputation: 31
You need to link to libpthread.so, usually located in /usr/lib. I believe there
is a switch in the project settings of KDevelop, if you are using it. Otherwise, set it in your makefile.

HTH
 
Old 02-08-2005, 08:52 AM   #4
JanusPaul
Member
 
Registered: Nov 2004
Location: Houston, Texas
Distribution: Ubuntu, Debian, Solaris, Free BSD
Posts: 82

Original Poster
Rep: Reputation: 15
Ah, ok thanks
Got it working !
 
Old 02-08-2005, 10:25 AM   #5
JanusPaul
Member
 
Registered: Nov 2004
Location: Houston, Texas
Distribution: Ubuntu, Debian, Solaris, Free BSD
Posts: 82

Original Poster
Rep: Reputation: 15
Now the main thread is exiting when the thread is created, I've tried pause() and sleep(), neither seem to prevent the main thread's exiting. I dunno what I'm doing wrong since this is all within a plugin for an existing server's software.
 
Old 02-08-2005, 03:24 PM   #6
JanusPaul
Member
 
Registered: Nov 2004
Location: Houston, Texas
Distribution: Ubuntu, Debian, Solaris, Free BSD
Posts: 82

Original Poster
Rep: Reputation: 15
Fixed it! For anybody with the same error, here's the answer! Don't use NULL for the thread ID pointer. Actually create a pthread_t variable, and point to it!
 
Old 02-08-2005, 03:41 PM   #7
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
Quote:
Originally posted by JanusPaul
Fixed it! For anybody with the same error, here's the answer! Don't use NULL for the thread ID pointer. Actually create a pthread_t variable, and point to it!
Oh, my. You don't have much experience in this and you seem to lack a good guide that can help you. Are you testing this and just using the man? Maby this can help you a bit: Linux POSIX Threads Tutorial

I used this tutorial and it helped me a lot with threads. Hope it can do some good for you too.
 
Old 02-09-2005, 03:43 PM   #8
JanusPaul
Member
 
Registered: Nov 2004
Location: Houston, Texas
Distribution: Ubuntu, Debian, Solaris, Free BSD
Posts: 82

Original Poster
Rep: Reputation: 15
Been using this:
http://www.mkssoftware.com/docs/api_index.asp
http://www.mkssoftware.com/docs/man3...d_create.3.asp
Quote:
PARAMETERS
thread
Is the location where the ID of the newly created thread should be stored, or NULL if the thread ID is not required.
Thanks for the additional link! Always learning new stuff.
 
Old 02-09-2005, 05:46 PM   #9
JanusPaul
Member
 
Registered: Nov 2004
Location: Houston, Texas
Distribution: Ubuntu, Debian, Solaris, Free BSD
Posts: 82

Original Poster
Rep: Reputation: 15
What about using the _strlwr() function? I have string.h included, tried adding -lstdc++ to GCC, no luck...
 
  


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
pthread zaman Programming 6 08-29-2004 04:04 PM
pthread and C++ gt73 Programming 17 11-04-2003 03:01 AM
about pthread c12ayon Programming 6 10-25-2003 04:37 AM
need help about pthread c12ayon Programming 1 10-24-2003 07:47 AM
Pthread rch Programming 1 05-28-2003 02:20 AM

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

All times are GMT -5. The time now is 11:46 AM.

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