由C 11库拒绝的AutoConf被编译器接受,被预处理器拒绝

Autoconf rejected by C++11 library accepted by compiler, reject by preprocessor

本文关键字:拒绝 处理器 预处理 编译器 AutoConf      更新时间:2023-10-16

我正在尝试将Rapidcheck集成到现有的C 代码库中。README表示,它需要C 11,并严重依赖其功能。现有代码库使用Automake来构建所有依赖关系。这是我将依赖项添加到 configure.ac中的方式:

  CXXFLAGS="$CXXFLAGS -Wall -Werror -Wno-missing-braces -std=c++11"
  CXXFLAGS="$CXXFLAGS -I/home/chris/dev/rapidcheck/include"
  CXXFLAGS="$CXXFLAGS -I/home/chris/dev/rapidcheck/include/rapidcheck"
  AC_CHECK_HEADERS(
      [rapidcheck.h],
      [AC_CHECK_LIB([rapidcheck], [main],[], [])],
      [])

这是我运行配置脚本时遇到的错误:

checking rapidcheck.h usability... yes
checking rapidcheck.h presence... no
configure: WARNING: rapidcheck.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: rapidcheck.h: proceeding with the compiler's result
checking for rapidcheck.h... yes
checking for main in -lrapidcheck... no

config.log

的内容
3501 configure:22873: checking rapidcheck.h usability
3502 configure:22873: g++ -std=c++11 -c -g -O2 -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wall -Werror -Wno-missing-braces -std=c++11 -I/home/chris/dev/rapidcheck/include -I/home/chris     /dev/rapidcheck/include/rapidcheck  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS conftest.cpp >&5
3503 configure:22873: $? = 0
3504 configure:22873: result: yes
3505 configure:22873: checking rapidcheck.h presence
3506 configure:22873: g++ -std=c++11 -E  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS conftest.cpp
3507 conftest.cpp:58:24: fatal error: rapidcheck.h: No such file or directory
3508 compilation terminated.

我认为这与没有最新的C 编译器有关。

这是我已经安装的C 版本:

chris@chris:~/dev/bitcoin$ g++ --version
g++ (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我认为是C 11兼容。

这与 automake无关,它与 autoconf有关。

特别是,您应该能够忽略此警告,因为AutoConf比预处理器更好地接受编译器输出。正如某人在评论中已经说过的那样,CPPFLAGS应用于通过-I标志来找到预处理器以找到标题,但是在这种情况下,鉴于这些标志根本不应在configure.ac中设置(而是BE BE),这确实不是很重要(由于安装位置由用户定义,因此从外部传递。)