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