编译一个依赖 Homebrew 安装的库,之前还能用的,升级系统之后,编译同样的项目就报找不到 .h 文件了。
clang -x c -v -E /dev/null
的结果是:
Apple LLVM version 7.0.0 (clang-700.0.72)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -main-file-name null -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.2 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fdebug-compilation-dir /usr/local -ferror-limit 19 -fmessage-length 114 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o - -x c /dev/null
clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target x86_64-apple-darwin15.0.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks (framework directory)
居然没有了 /usr/local/include
跑 brew doctor
也不行。
解决这个问题的正确姿势是怎么样的?
1
regeditms 2015-10-02 18:07:51 +08:00
哦 ,一遍编译查找确实没有 /usr/local/include 你需要添加查找路径
|
2
holulu OP @regeditms .h 通过 export C_INCLUDE_PATH="..." 可以解决,但找不到库,通过 export DYLD_LIBRARY_PATH="..." 不行。
是不是环境变量错了? |
3
regeditms 2015-10-02 18:21:51 +08:00
一般情况下没特殊性 头文件就用 CPATH ,动态库 添加到 DYLD_LIBRARY_PATH 。
|
4
regeditms 2015-10-02 18:22:53 +08:00
继续上一条,你添加动态库路径 你电脑 csrutil disable 了吗?如果没有的话 是不允许 添加外部动态库路径的。
|
6
holulu OP 无聊地 `export LIBRARY_PATH=/usr/local/lib` 就解决了。
|