GCC在/usr/local/include中找不到头文件

3

我最近安装了libechonest和它的所有依赖项,但是要包含它的头文件(在/usr/local/include/echonest/),我必须指定整个路径,即#include "/usr/local/include/echonest/Artist.h"而不是只需写#include <Artist.h>

alexcannon$ gcc -g -o geoEchoNest geoEchoNest.c -lechonest
geoEchoNest.c:6:10: fatal error: 'Artist.h' file not found
#include "Artist.h"

这是为什么呢?根据GCC文档,它应默认查找/usr/local/include

GCC looks in several different places for headers. On a normal Unix system, if you do not >instruct it otherwise, it will look for headers requested with #include in:

/usr/local/include
libdir/gcc/target/version/include
/usr/target/include
/usr/include

我该怎么解决?对于其他库也有同样的问题,例如我必须使用#include"/usr/local/include/QtCore/QDebug"而不是include <QDebug>,所以这并不仅仅是一个echonest的问题。

/usr/local/include的权限为drwxrwxr-x。这是我的gcc信息:

alexcannon$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-    include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

我搜索了很多类似的GCC #include问题,但唯一一个特别涉及在/usr/local/include找到文件问题的问题是关于XCode的

如果需要更多信息,请告诉我,谢谢提前帮助。

1个回答

2
包含路径不会递归搜索,请尝试使用以下方法。
#include <echonest/Artist.h>

3
如果进行递归搜索,这将是一场无法遏制的灾难……我刚数了一下/usr/include目录下有六个不同的error.h文件。:-D - DevSolar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接