library not found for -lrt with QtCreator [mac os]

The linker cannot find librt which is probably the Posix real time extensions library. I don’t think this is available on OSX. Googling gives this from Apple developer lists

Question from list

I’m trying to build a simulator developed in my university (on Linux)
and I get error by the linker that seems unable to find librt.a – in
the code is used for clock_gettime() and I would like to know if
there’s a port of such library, or some other similar function that
allows me to compile even on Mac OS X.

Answer
librt.a is the System V name of the library containing the POSIX
Advanced Realtime [RT} Option functions. The specific function you are
asking about is part of the [TMR] option. If Mac OS X supported it, it
would be in libSystem.B,dylib, not librt.a. The function in question
is not supported by Mac OS X.

Your code should check to see whether optional to implement things
above and beyond the UNIX standard are implemented in the target OS,
and if they aren’t, use a different interface.

Leave a Comment