-1

This is my makefile:

program : program.o
          gcc -o program program.o
program.o : program.c library.h
            gcc -c program.c

In "library.h" I've got the headers, but I have a problem with the semaphores. It says "undefined reference to sem_open , sem_post, sem_wait. . ."

  • 1
    possible duplicate of [sem\_open doesn't work with Ubuntu : undefined reference to \`sem\_open'](http://stackoverflow.com/questions/11500879/sem-open-doesnt-work-with-ubuntu-undefined-reference-to-sem-open) - please at least type your error message in Google before posting here. The first four results for "undefined reference to sem_open" are Stack Overflow posts. – Mat May 24 '13 at 16:29

1 Answers1

0

You need to link to the pthread library - libpthread. Try changing your link command to

program : program.o
          gcc -pthread -o program program.o
simonc
  • 41,632
  • 12
  • 85
  • 103