c - 使用 -Wall 运行 ./configure 会导致找不到库

标签 c autotools automake

我想在 autotools 项目中使用 -Wall-Werror 作为 gcc 的标志,但我不想将它们放在我的配置中。交流

因此,我尝试使用 ./configure CFLAGS='-Wall -Werror',只是从我的一个 AC_SEARCH_LIBS 宏调用中得到一个错误:

AC_SEARCH_LIBS([pow], [m], , AC_MSG_ERROR([Could not find standard math library.]))

在添加了 CFLAGS 的情况下运行配置时出现错误:

configure: error: Could not find standard math library.

我在这里做错了什么?在没有设置 CFLAGS 变量的情况下,配置工作正常。

最佳答案

如您所知,将编译警告提升为错误会混淆 ./configure

您可以做的是在 make 时传递自定义 CFLAGS:

$ ./configure
$ make CFLAGS='-O2 -g -Wall -Wextra -Werror'

另一种选择是 William Pursell 的方法:向 ./configure 添加一个选项以打开 -Werror(如果支持):

(配置.ac)

AC_ARG_ENABLE([werror],
              [AS_HELP_STRING([--enable-werror], [Use -Werror @<:@no@:>@])],
              [:],
              [enable_werror=no])
AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes])

(生成文件.am)

if ENABLE_WERROR
AM_CFLAGS += -Werror
endif

关于c - 使用 -Wall 运行 ./configure 会导致找不到库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14266168/

相关文章:

python - 在 Yocto bitbake 中为 autotools 设置 python dist-packages 路径

c - 如何强制测试程序链接到libtool构建的静态库

installation - 构建PAM模块并安装到/lib/security

autotools - automake:添加对 _PROGRAMS 目标的依赖关系

c - 本地错误 : ' is already registered with AC_CONFIG_FILES; and/or $'\r': command not found

c - 将 unsigned long long 与 rpcgen 一起使用会出错

c - 不使用 scanf 接受整数

C位域/数组

latex - Autoconf/Automake 条件和 dist 规则

c - 如何在 C 中创建一个数组来容纳 2 种相似类型的结构?