Skip to content

Instantly share code, notes, and snippets.

@jadia
Last active November 5, 2018 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jadia/6a6a7510b7432275a853020f83549569 to your computer and use it in GitHub Desktop.
Save jadia/6a6a7510b7432275a853020f83549569 to your computer and use it in GitHub Desktop.
unable to compile sem_open in UBUNTU

Problem

/tmp/ccz11fg4.o: In function `main':
firstCode.c:(.text+0x24): undefined reference to `sem_open'
firstCode.c:(.text+0x34): undefined reference to `sem_post'
firstCode.c:(.text+0x4c): undefined reference to `sem_wait'

Solution

Link with pthread library.

compile with -pthread

gcc filename.c -o file.out -lpthread

Works on Ubuntu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment