问题
Moving from 10.8
to 10.9
broke my WFDB installation, library not found for -lwfdb
.
This program
#include <wfdb/wfdb.h>
int main(void) { return 0; }
errors on linking (since Mavericks, -I/usr/include
has to be included, otherwise the compiler errors):
567 ~/ clang -I/usr/include c.c -o c -lwfdb
ld: library not found for -lwfdb
I've tried also adding -L/usr/lib
(where libwfdb.10.5.20.dylib
, libwfdb.10.dylib
and libwfdb.dylib
are located), but ld
still can't find -lwfdb
,
Seems like Mavericks completely removed gcc
. The LD_LIBRARY_PATH
seems to be runtime-only. Everything worked under Mountain Lion. What else should I try?
A solution
After perusing clang
's -v
erbose output (continued below) ...
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)
... I have placed libwfdb.10.5.20.dylib
and libwfdb.dylib
(ln -s
ed to the 1st file) from /usr/lib
inside /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/
in its usr/lib
.
The program now links fine. But, this surely can't be a long-term solution? What is the best way to proceed in 10.9? E.g. adding a link to /usr/lib
inside current -syslibroot
would break on each Xcode upgrade ... no good.
回答1:
Try clang -v -I/usr/include c.c -o c -lwfdb
for verbose output of what clang
tries to do when searching for -lwfdb
. Then, verify the files are there.
回答2:
Tried adding
/usr/include
to$PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:
...
Well, that jut cannot work. $PATH
is the search path for executables.
You should add /usr/include
to the include path. Either via a compiler invocation - just add -I/usr/include
to the command line - or in a clang
-specific way I don't know about.
来源:https://stackoverflow.com/questions/20029654/mavericks-library-not-found-for-lwfdb