当我尝试
$ make depend -f gcc.mak
我的 Ubuntu 机器上的一个中间件我得到了这个
/usr/include/../include/limits.h:125:26: error: no include path in which to search for limits.h
这是limits.h:125周围的内容:
/* Get the compiler's limits.h, which defines almost all the ISO constants. We put this #include_next outside the double inclusion check because it should be possible to include this file more than once and still get the definitions from gcc's header. */ #if defined __GNUC__ && !defined _GCC_LIMITS_H_ /* `_GCC_LIMITS_H_' is what GCC's file defines. */ # include_next <limits.h> #endif
我试过设置
$ export INCLUDE=/usr/lib/gcc/x86_64-linux-gnu/4.3/include-fixed/ $ export C_INCLUDE_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.3/include-fixed/ $ export CPLUS_INCLUDE_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.3/include-fixed/
(这是我在我的系统上发现另一个 limits.h 的地方)。我已经安装了 libc6-dev,会不会是它的 limits.h 被另一个包覆盖了?我需要另一个 -dev 包吗?或者是否需要环境变量;也许这可以通过其他方式规避?
最佳答案
我在交叉编译时遇到过这个问题。当您执行“make depend”时,Makefile 将调用 makedepend 程序,如以下分配所示:
MAKEDEPPROG=makedepend
makedepend 只搜索一些以 /usr/include
开头的默认包含目录
因为 #include_next
指令意味着在搜索路径中包含命名包含文件的下一个找到的实例,如果找不到另一个实例,这将失败。
对我来说,解决方案是让 makedepend 首先搜索我的交叉编译器包含目录。我通过更改 MAKEDEPPROG
赋值以包含 -I
指令来做到这一点:
MAKEDEPPROG=makedepend -I < path/to/cross-compiler/include-fixed >
我建议阅读 makedepend 程序(我以前对此一无所知)。例如,makedepend 不会使用环境搜索路径对我来说并不明显。 -I
指令将指定的搜索路径放在 makedepend 的默认路径之前。
关于c++ - GCC 构建问题 (#include_next limits.h),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/871952/