【问题标题】:configure: error: C preprocessor fails sanity check配置:错误:C 预处理器未通过完整性检查
【发布时间】:2013-02-09 02:51:27
【问题描述】:

我正在 Ubuntu 12.04 x86_64 上编译几个库。首先,我用 GCC 4.7.2 编译了库,一切顺利。然后我尝试使用 Inte Composer 2013 u2 重新编译它们。出于这个目的,我做到了:

export CC=/opt/intel/composer_xe_2013.2.146/bin/intel64/icc
export CPP=/opt/intel/composer_xe_2013.2.146/bin/intel64/icpc

然后我运行./configure 并得到以下错误:

checking how to run the C preprocessor... /opt/intel/composer_xe_2013.2.146/bin/intel64/icpc
configure: error: in `/var/www/workspace/freetype/freetype-2.4.11/builds/unix':
configure: error: C preprocessor "/opt/intel/composer_xe_2013.2.146/bin/intel64/icpc" fails sanity check
See `config.log' for more details
make: *** [setup] Error 1

配置日志文件包含此错误:

configure:3345: checking how to run the C preprocessor
configure:3415: result: /opt/intel/composer_xe_2013.2.146/bin/intel64/icpc
configure:3435: /opt/intel/composer_xe_2013.2.146/bin/intel64/icpc  conftest.c
conftest.c(14): error: identifier "Syntax" is undefined
             Syntax error
             ^

conftest.c(14): error: expected a ";"

compilation aborted for conftest.c (code 2)

configure:3435: $? = 2
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "FreeType"
| #define PACKAGE_TARNAME "freetype"
| #define PACKAGE_VERSION "2.4.11"
| #define PACKAGE_STRING "FreeType 2.4.11"
| #define PACKAGE_BUGREPORT "freetype@nongnu.org"
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|            Syntax error
configure:3435: /opt/intel/composer_xe_2013.2.146/bin/intel64/icpc  conftest.c
conftest.c(14): error: identifier "Syntax" is undefined
             Syntax error
             ^

conftest.c(14): error: expected a ";"

compilation aborted for conftest.c (code 2)

这里有什么问题?

【问题讨论】:

  • 查看conftest.c 文件以了解正在测试的内容。
  • 本应写入conftest.c 文件的内容(有用地包含在显示的日志中)因“语法错误”而出错,结果无法编译。要找出这意味着探索 autotools inards 的曲折(颤抖),也许是之前运行的剩余部分。再试一次,确保没有保留以前的构建(可能是make distclean 或类似的东西)。
  • 我尝试使用make cleanmake distclean 进行清理,但仍然是同样的问题。我下载了另一个库并尝试了相同的方法,但以同样的方式失败了。然后我切换回 GCC 并编译了两个库。

标签: linux compiler-errors configure icc


【解决方案1】:

问题很可能是 GNU 使隐式变量 表示“你的 C++ 编译器”不是CPP 而是CXX,而CPP 是 表示“你的 C 预处理器”的隐式变量;所以 你的

export CPP=/opt/intel/composer_xe_2013.2.146/bin/intel64/icpc

告诉configure icpc 是预处理器,大概离开CXX 默认为 g++。

./configure 错误支持这一点:

检查如何运行 C 预处理器... /opt/intel/composer_xe_2013.2.146/bin/intel64/icpc

试试:

export CXX=/opt/intel/composer_xe_2013.2.146/bin/intel64/icpc

或者只是:

./configure CXX=/opt/intel/composer_xe_2013.2.146/bin/intel64/icpc

【讨论】:

  • 好收获! (我忽略了它)
  • 当然,这解决了问题,但每次编译时都会强制您定义 CPP 变量。为什么不首先解释如何编译 GCC 以在正确的位置查找 CPP?
  • 哇。这也为我修复了它。那么为什么这会导致生成的 confdefs.h 文件中出现“语法错误”呢?谈论红鲱鱼......
【解决方案2】:

FWIW,我今天遇到了这个问题,我的解决方案是

export CPP='<path to icpc> -E'

也就是说,告诉 configure 预处理器应该使用-E 标志运行。

【讨论】:

  • 这是多年后的事了,但谢谢。我从没想过绝对路径和 -E 标志是必要的,但它是!!
【解决方案3】:

谢谢 Menno,在我的情况下,导出并没有完全做到这一点,但它已经接近了。传递 CPP=... 来配置就行了:

mkdir build
cd build
../configure --prefix=/usr/local/gcc/ CC=/usr/local/gcc/bin/gcc \
 CXX=/usr/local/gcc/bin/g++ CPP='/usr/local/gcc/bin/g++ -E'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-18
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多