1

Although more a novice I try to explain my problem. I am on a Mac and use command line to build the executable. The compiling command works successfully on Ubuntu.

cc   program.o file1.o file2.o file3.o file4.o -lm -lrt -o program
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [program] Error 1

If I run with -v command I get the following:

Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -o program program.o file1.o file2.o file3.o file4.o -lm -lrt -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/lib/darwin/libclang_rt.osx.a
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any hint?

I found in this post what -lm -lrt mean but still could not figure out a solution.

Update 1: According to this link -lrt is not available for Mac.

Update 2: I have found two possible solutions: (a) either to remove completely the flag or (b) use the -lSystem.B instead. The real-time extensions seems to be in libSystem.B.dylib as explained here.

maelvls
  • 78
  • 12
AjanO
  • 433
  • 1
  • 9
  • 20
  • Error is `ld: library not found for -lrt`. This means that the linker (`ld`) couldn't find the library providing POSIX realtime extensions. Either it is not installed or you should provide its path with `-L` option. – mouviciel Jun 06 '16 at 07:08
  • @ mouviciel According to [link](http://stackoverflow.com/questions/6754032/what-library-does-ld-option-lrt-refer-to-bionic-libc) *-lrt* is not available for Mac – AjanO Jun 06 '16 at 07:46
  • 1
    I guess in the end I answered to my own question. Thus, I updated with two possible solutions. – AjanO Jun 06 '16 at 08:26
  • You can answer your own question. If one of the solutions you found works, this would help other people with the same problem. – mouviciel Jun 06 '16 at 08:46

0 Answers0