Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Linker error - undefined reference to `sem_init'

    I am calling sem_* functions in my test proram. It compiles well, but the linker complains undefined reference to `sem_init'. It should be in libc according to man.

    I am using GCC 4.0, but I don't thik it is a problem because I know other people (with no 4.0) also got this error.

    BTW, I am new to Linux programming.

  2. #2
    I think that the answer might be to compile with -lpthreads

    One thing I find frustrating about Linux is that the man pages for C functions
    do not say how to link the appropriate library.As opposed to Solaris for example
    where they do.

  3. #3
    It sovles the problem. Thanks.

    Indeed, it's a bad thing not to list the library each function should link to.

    Okay, it's a bad thing for us newbies, but not necessarily for gurus

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts