sem_open problem
Green Light
greenlightrh@yahoo.com.ar
Fri May 2 16:25:00 GMT 2003
It works fine!!
Thanks Ravi!!
BRA> Hello,
BRA> You have to use librt to get semaphore calls. Try
BRA> gcc ./TestProc.cpp -o ./TestProc -lrt.
BRA> It should work.
BRA> regards,
BRA> Ravi
BRA> -----Original Message-----
BRA> From: Green Light [mailto:greenlightrh@yahoo.com.ar]
BRA> Sent: Friday, May 02, 2003 2:12 PM
BRA> To: gcc-help@gcc.gnu.org
BRA> Subject: sem_open problem
BRA> This is a very simple application, i want to create a semaphore and use
BRA> it.
BRA> I'm using version:
BRA> gcc (GCC) 3.2.3 20030222 (Red Hat Linux 3.2.2-5)
BRA> installed by Red Hat Linux 9 installer
BRA> I'm compiling using:
BRA> gcc ./TestProc.cpp -o ./TestProc
BRA> The return is:
BRA> In function 'main':
BRA> reference to 'sem_open' without definition
BRA> collect2: ld returned 1 exit status
BRA> This is the code:
BRA> //=================================================================
BRA> #include <semaphore.h>
BRA> #include <fcntl.h>
BRA> int main()
BRA> {
BRA> sem_t *unSem;
BRA> int oflag = O_CREAT;
BRA> mode_t mode = 0644;
BRA> const char semNombre[] = "/unSem.sem1";
BRA> unsigned int value = 0;
BRA> int sts;
BRA> unSem = sem_open(semNombre, oflag, mode, value);
BRA> if (unSem == (void *)-1)
BRA> {
BRA> printf("fallo");
BRA> }
BRA> else
BRA> {
BRA> printf("Semaforo creado");
BRA> }
BRA> return 0;
BRA> }
BRA> //=================================================================
BRA> Any help or sugestion for me?
BRA> Thanks!, Pablo.
More information about the Gcc-help
mailing list