LinuxQuestions.org
Visit Jeremy's Blog.
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 12-05-2006, 02:57 PM   #1
beanxp
LQ Newbie
 
Registered: Nov 2006
Posts: 4

Rep: Reputation: 0
problem with the thread programming


When I tried to do some hread programming in my linux system, I have some problems:
Code:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>

void main()
{
  ...
  res = pthread_create(&a_thread, NULL, thread_function, (void *)message);
  ...
}
When I compiled this program, I got the error message:
undefined reference to `pthread_create'

And the POSIX version is 200112. Doesn't the system support thread program? or I need to modify the code?
Thanks!
 
Old 12-05-2006, 03:30 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
add -lpthread to the linking command.
 
Old 12-05-2006, 03:48 PM   #3
beanxp
LQ Newbie
 
Registered: Nov 2006
Posts: 4

Original Poster
Rep: Reputation: 0
It works.
Thanks!

Quote:
Originally Posted by matthewg42
add -lpthread to the linking command.
 
Old 12-05-2006, 09:36 PM   #4
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
There is a dedicated programming forum on here on LQ.

Next time you might want to post questions related to programming there.
 
Old 12-06-2006, 09:54 AM   #5
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Moved: This thread is more suitable in the Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


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
Thread programming skie_knite007 Programming 3 01-10-2006 11:36 AM
Thread programming Megasms Programming 2 11-05-2005 12:09 AM
POSIX Thread programming problem... rajsun Programming 0 10-07-2005 11:18 PM
POSIX thread Programming msriram_linux Programming 4 11-21-2004 03:14 PM

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

All times are GMT -5. The time now is 09:31 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