This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Help : Threads in AIX


>>>>> Swaminathan, Sangeetha (Cognizant) writes:

> I have  CDoc.h and CDoc.C.
> My CDoc.h has #include<pthread.h>, and a member variable pthread_mutex_t
> mutex;
> 
> In CDoc.C,
> The constructor has pthread_mutex_init(&mutex, NULL);
> and MyFunction() calls: pthread_mutex_lock (&mutex); and
> pthread_mutex_unlock(&mutex);
> and the destructor calls pthread_mutex_destroy(&mutex);
> 
> I am able to compile CDoc.C and generate a CDoc.o
> But when I create a libCDoc.so (a shared object) from the CDoc.o, I get
> these errors:
> 
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_init
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_destroy
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
> 
> However, in another case: Main.h and Main.C where I don't define any
> classes (I used the other classes already defined):
> I create threads, and use the above thread functions as well. I don't get
> the error. But I don't builb a .so also.
> 
> What could be the problem??

	Are you compiling your pthread program with

gcc -pthread ?

	You do not say which version of GCC you are using.  There was a
problem with GCC 3.0 sometimes creating a dependency on libpthread because
of a G++ header file problem.  Upgrade GCC to GCC 3.1.1 or GCC 3.2 to fix
this. 

David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]