pthreads in Solaris gcc

Started by
1 comment, last by Rattrap 17 years, 5 months ago
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.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

Advertisement
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.
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.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

This topic is closed to new replies.

Advertisement