This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]