Sign in to follow this  
Rattrap

pthreads in Solaris gcc

Recommended Posts

using the following command line g++ -lpthread -I/export/home/root/Programming/loki-0.1.5/include ../Except ionHandling/*.cpp ../Loki/*.cpp ../stub.cpp -o gccout 2> resultgcc.txt I successfully compiled my code in cygwin (gcc 3.4.4). I then tried compiling it in gcc (3.4.3) in Solaris 10. I'm getting the following errors Undefined first referenced symbol in file sem_destroy /var/tmp//cc6dg0N3.o sem_init /var/tmp//cc6dg0N3.o sem_post /var/tmp//cc6dg0N3.o sem_wait /var/tmp//cc6dg0N3.o ld: fatal: Symbol referencing errors. No output written to gccout collect2: ld returned 1 exit status So it looks like the linker can't find the semaphore part of the pthread library, but I'm not that well versed in gcc. The code does use the headers pthread.h and semaphore.h, but it doesn't seem to have any problems with the pthread_ calls, just the sem_ calls.

Share this post


Link to post
Share on other sites
You can use nm to view the symbols an object file contains. Check if libpthread contains the semaphore functions (it should and the symbol type should be T). If not, you can use ldd to view a library's dependencies. Look up libpthread's dependencies and see if any of them contain the functions you need.

Also, try a simple test case. Write a program that inits a semaphore and then destroys it, and see if you can build it.

Share this post


Link to post
Share on other sites
Thanks for the suggestion.

Turns out it was I needed to add the -lposix4 to the g++ parameters. The semaphore kind of exists seperate from the rest of pthread.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this