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

Accepted answer
Score: 16

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

Question from list

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

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

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

Score: 12

Why does the program need librt?

I know that 5 some platforms (Solaris comes to mind) require 4 librt for some functions which might exist 3 in other libraries in your OS. (sem_init() et 2 al. are like this)

You might try to link 1 without -lrt and see if it works.

More Related questions