[CentOS] POSIX semaphores in CentOS 5.1?

Thu Feb 7 02:44:20 UTC 2008
Jonathan Berry <berryja at gmail.com>

On Feb 6, 2008 5:42 PM, MHR <mhullrich at gmail.com> wrote:
> According to the man pages for sem_wait, etc., POSIX semaphores are
> available in Linux 2.6 (with the right NTPL threading in glibc).
>
> However, I have a program that compiles just fine but won't link because it
> can't find the library for the semaphore operations.
>
> What am I missing?
>
> I ran a find and grep through all the libc's on the system and they turned
> up nothing:
>
> $ find /lib /usr/lib -name "*libc\.*" -print -exec nm {} 2>/dev/null \; |
> grep sem_
>
> (no results)
>
> Time is critical (yeah, I know...).

>From man sem_overview:
"Linking
       Programs  using  the POSIX semaphores API must be compiled with cc -lrt
       to link against the real-time library, librt."

Are you linking with -lrt?

Jonathan