【问题标题】:Mavericks: library not found for -lwfdb小牛队:找不到 -lwfdb 的库
【发布时间】:2013-11-17 10:35:18
【问题描述】:

10.8 移动到10.9 破坏了我的WFDB 安装,找不到-lwfdb 的库

这个程序

#include <wfdb/wfdb.h>
int main(void) { return 0; }

链接错误(因为 Mavericks,-I/usr/include 必须包括在内,否则 编译器 错误):

567 ~/  clang -I/usr/include c.c -o c -lwfdb
ld: library not found for -lwfdb

我也试过添加-L/usr/liblibwfdb.10.5.20.dyliblibwfdb.10.dyliblibwfdb.dylib所在的位置),但ld仍然找不到-lwfdb

似乎小牛队完全删除了gccLD_LIBRARY_PATH 似乎仅适用于运行时。一切都在山狮的带领下工作。 我还应该尝试什么?


一个解决方案

在仔细阅读clang-verbose 输出后(续下文)...

568 ~/  clang -v -I/usr/include c.c -o c -lwfdb
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name c.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 224.1 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -I /usr/include -fdebug-compilation-dir /Users/blaise/ -ferror-limit 19 -fmessage-length 170 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fencode-extended-block-signature -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/64/3l9hbm994q37l_bw79kf15bm0000gp/T/c-2iLIU4.o -x c c.c
clang -cc1 version 5.0 based upon LLVM 3.3svn default target x86_64-apple-darwin13.0.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -o c /var/folders/64/3l9hbm994q37l_bw79kf15bm0000gp/T/c-2iLIU4.o -lwfdb -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -lwfdb
clang: error: linker command failed with exit code 1 (use -v to see invocation)

...我已将/usr/lib 中的/usr/lib 中的libwfdb.10.5.20.dyliblibwfdb.dylibln -sed 到第一个文件)放在 its usr/lib 中的/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/ 中。

程序现在链接正常。 但是,这肯定不是长久之计吗?在 10.9 中进行的最佳方式是什么? 例如在当前-syslibroot 中添加指向/usr/lib 的链接会在每次Xcode 升级时中断...不好。

【问题讨论】:

    标签: c linker clang header-files osx-mavericks


    【解决方案1】:

    尝试clang -v -I/usr/include c.c -o c -lwfdb 以获得clang 在搜索-lwfdb 时尝试执行的操作的详细输出。然后,验证文件是否存在。

    【讨论】:

    • 我已手动将wfdb 库放入ld 的搜索路径中;程序现在链接。对我更新的问题有什么建议吗?
    • @courteous 为什么你不喜欢-L/path/to/library
    • 已经尝试过但没有成功:-L/usr/lib 仍然无法链接。 (尝试在问题的历史中;只是试图保持简短。)尽管如此,这个库肯定不是在 Mavericks 下唯一被破坏的库......这不可能是 前进的道路. :)
    【解决方案2】:

    尝试将/usr/include 添加到$PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:...

    好吧,那是行不通的。 $PATH 是可执行文件的搜索路径。

    您应该将/usr/include 添加到包含路径。通过编译器调用 - 只需将 -I/usr/include 添加到命令行 - 或以 clang 特定的方式,我不知道。

    【讨论】:

    • 我确实尝试了-I/usr/include 调用。现在,fatal error: 'wfdb/wfdb.h' file not found 消失了,但-l 选项仍然触发链接器错误:ld: library not found for -lwfdb
    • @courteous 然后另外将库的路径添加到链接器路径 - 使用-L
    猜你喜欢
    • 1970-01-01
    • 2014-01-24
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-09
    • 1970-01-01
    相关资源
    最近更新 更多