Linking to POSIX semaphores
Peter Rockett
p.rockett@sheffield.ac.uk
Tue Nov 3 20:01:00 GMT 2009
I am trying to use POSIX named semaphores. Stripping it down, if I compile
the program:
#include <fcntl.h>
#include <sys/stat.h>
#include <semaphore.h>
int main()
{
sem_open("Sem1", O_CREAT, S_IRWXU, 0);
sem_unlink("Sem1");
return 0;
}
and link it to /usr/lib/librt.a (which the Linux man pages say is the
necessary library), I get a link error saying that sem_open() and
sem_unlink() are unresolved. Looking inside librt.a using the nm utility, I
cannot find any reference to the POSIX semaphores. Am I doing something
dumb? Where do I find the implementations of the POSIX semaphores? Am I
misinterpreting the man pages somehow?
(I am using Ubuntu 9.1 with gcc-4.4.1.)
Peter
More information about the Gcc-help
mailing list