This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
sem_open problem
- From: Green Light <greenlightrh at yahoo dot com dot ar>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 2 May 2003 10:42:14 +0200
- Subject: sem_open problem
- Reply-to: Green Light <greenlightrh at yahoo dot com dot ar>
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.