This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Help : Threads in AIX
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: "Swaminathan, Sangeetha (Cognizant)" <SSangeet2 at CHN dot COGNIZANT dot COM>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 17 Aug 2002 11:59:52 -0400
- Subject: 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