Macos Mac的数学库和POSIX实时扩展

Macos Mac的数学库和POSIX实时扩展,macos,clang,ld,cc,Macos,Clang,Ld,Cc,虽然我是个新手,但我试图解释我的问题。 我在Mac上,使用命令行构建可执行文件。编译命令在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: *** [prog

虽然我是个新手,但我试图解释我的问题。 我在Mac上,使用命令行构建可执行文件。编译命令在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
如果使用-v命令运行,则会得到以下结果:

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)
有什么提示吗

我找到了-lm-lrt的意思,但仍然无法找到解决方案

更新1:根据-lrt不适用于Mac


更新2:我找到了两种可能的解决方案:(a)要么完全删除标志,要么(b)改用-lSystem.b。如前所述,实时扩展似乎位于libSystem.B.dylib中。

错误为
ld:library找不到-lrt
。这意味着链接器(
ld
)找不到提供POSIX实时扩展的库。要么它没有安装,要么你应该用
-L
选项提供它的路径。@mouviciel根据-lrt不可用于mac我想最后我回答了我自己的问题。因此,我更新了两种可能的解决方案。您可以回答自己的问题。如果您找到的解决方案中有一个可行,这将有助于解决相同问题的其他人。错误为
ld:library not found for-lrt
。这意味着链接器(
ld
)找不到提供POSIX实时扩展的库。要么它没有安装,要么你应该用
-L
选项提供它的路径。@mouviciel根据-lrt不可用于mac我想最后我回答了我自己的问题。因此,我更新了两种可能的解决方案。您可以回答自己的问题。如果您找到的解决方案中有一个可行,这将帮助其他有相同问题的人。