1

I have a Raspberry Pi with an up to date Raspbian installation and I am using code blocks tools to compile an example program from PIGPIO. The compile fails with an:

undefined reference to 'clock_nanosleep'

From what I have been able to learn from google searches it seems that clock_nanosleep is a function that requires time.h to be included.

What library or code is missing that contains clock_nanosleep and how do I go about explaining to Code::Blocks where to find it?

1 Answer 1

1

A great Linux resource for C functions are the man pages.

If you execute man clock_nanosleep it will tell you which includes you need. It will also tell you that you may need to include the real time library with -lrt.

You are probably missing -lrt in your build command.

1
  • Wonderful, thank you very much. You diagnosed the problem exactly, I was missing the -lrt
    – TimxDunn
    Dec 15, 2016 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.