Multithreaded Programming Guide

Linking With -lrt for POSIX Semaphores

The Solaris semaphore routines, sema_*(3THR), are contained in the libthread library. By contrast, you link with the -lrt library to get the standard sem_*(3R) POSIX 1003.1c semaphore routines described in Semaphores.