OSX gcc没有找到已安装的库

时间:2014-08-24 02:11:47

标签: c++ c macos gcc clang

我正在重新发现编译C的恐怖。我刚刚http://libtins.github.io安装libtins,按照通常的./configure - > make - > sudo make install模式。

sudo make install肯定会在/usr/local/include/tins中添加标题,但似乎g++看不到它们。

根据建议here,我尝试运行gcc -x c++ -v -E /dev/null以查看包含路径。

clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.3.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:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/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.

我原本希望在那里看到/usr/local/include。现在Xcode应用程序内的默认路径路径是否全部?

app.cpp

#include <tins/tins.h>

int main() {
    return 1;
}

编译命令

g++ app.cpp -ltins

结果

app.cpp:3:10: fatal error: 'tins/tins.h' file not found

知道如何让g++查看标题吗?

1 个答案:

答案 0 :(得分:5)

编译时你没有设置include path。因此,正确的编译行应该是:

g++ app.cpp -I/usr/local/include -L/usr/local/lib -ltins