Link to home
Start Free TrialLog in
Avatar of william007
william007

asked on

undefined reference to `sem_init'

#include <semaphore.h>
#include <unistd.h>

static sem_t count_sem;
int main(int argc, char* argv[]){
sem_init(&count_sem,1,3);
while(1){
      sem_wait(&count_sem);
      fork();
      if(getpid()==0){
      
      }
}
}


I get the following problem when I compile using gcc
/tmp/cc4Pal2o.o: In function `main':
contoller.c:(.text+0x29): undefined reference to `sem_init'
contoller.c:(.text+0x35): undefined reference to `sem_wait'
collect2: ld returned 1 exit status


What is the problem and how to correct it? (My platform is Linux Fedora Core 5. )
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of william007
william007

ASKER

Thanks=)