The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
hi probs with rm command madhu_aqua14 UNIX for Dummies Questions & Answers 13 03-05-2007 04:58 AM
lpthread error when trying to compile static BIND MixmasterMike UNIX for Advanced & Expert Users 0 07-25-2005 08:25 PM
More SSH probs ... frustrated1 SUN Solaris 2 06-17-2005 05:18 AM
copy probs svennie UNIX for Dummies Questions & Answers 12 11-18-2004 06:53 AM
probs compiling lex sinner Shell Programming and Scripting 0 04-13-2004 11:50 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-02-2008
Registered User
 

Join Date: Nov 2007
Posts: 73
probs compiling with gcc + lpthread

Im trying to write a program atm which uses mutexes to control thread access to a certain code section ( the critical section).

However, whenever I compile the code using gcc I get the following message from gcc

Unresolved text symbol "pthread_mutex_lock"
Unresolved text symbol "pthread_mutex_unlock"


I initalise my mutex as follows, after including <pthread.h> in my code

Code:
pthread_mutex_init(&cs_mutex,NULL);
The critical section is accessed in the following way. Note that this code segment is generic as my threads perform the same functionality

Code:
pthread_mutex_lock(&cs_mutex);

/*
Do critical section stuff here

*/
pthread_mutex_unlock(&cs_mutex);



I have included the -lpthread (which is needed to support thread functionality in the program ) in the compiling command, so I cannot understand why my code is not compiling

Last edited by JamesGoh; 03-02-2008 at 09:01 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 03-02-2008
Registered User
 

Join Date: Nov 2007
Posts: 73
Hi guys

I found out what the problem was

I mis-spelt thread as thead (slaps himself over the head) in pthread_mutex_lock and pthread_mutex_unlock which was why the compiler couldn't identify it :P

ohh the joys of spelling mistakes

cheers
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0