Jep*_*ron 1 c c++ macos gcc clang
我重新发现我刚刚安装编译C的恐怖libtins从http://libtins.github.io,通常如下./configure- > make- > sudo make install模式.
sudo make install肯定把标题放入,/usr/local/include/tins但它似乎不能g++看到它们.
按照这里的建议,我尝试运行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.
Run Code Online (Sandbox Code Playgroud)
我原本希望能/usr/local/include在某处看到.现在Xcode应用程序内的默认路径路径是否全部?
app.cpp
#include <tins/tins.h>
int main() {
return 1;
}
Run Code Online (Sandbox Code Playgroud)
编译命令
g++ app.cpp -ltins
结果
app.cpp:3:10: fatal error: 'tins/tins.h' file not found
知道如何g++查看标题吗?
编译时没有设置包含路径.因此,正确的编译行应该是:
g++ app.cpp -I/usr/local/include -L/usr/local/lib -ltins
Run Code Online (Sandbox Code Playgroud)