When I tried to create a project on Linux, I got Error: undefined symbol clock_gettime . So I realized that I need to add -lrt to the build (gcc) command. However, now it will not compile on OS X: ld: library not found for -lrt . I donβt know exactly where this function is called called in statically linked code, but it seemed to work fine in OS X without librt. The linked code probably uses the alternative behind #if __APPLE__ or something.
Is there a way I can tell gcc to only link librt if necessary, or if it exists? If not, how do I create a makefile with OS specific commands? I do not use autoconf or anything like that.
The Makefile is quite complex, but the operational part:
CC := g++
source share