我想在 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/