DNS BIND : 编译配置整理 - 如何添加编译选项以及-Werror的处理

对BIND进行configure配置,加入-Wall与-Werror编译选项,通过–help查询如何添加

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  LT_SYS_LIBRARY_PATH
              User-defined run-time library search path.
  CPP         C preprocessor

使用CFLAGS环境变量即可

配置如下
./configure CFLAGS="-Wall -Werror" --without-openssl

但是在配置过程中出现错误,最后的错误如下:

checking st_mtim.tv_nsec... no
checking for type rlim_t... no
checking type of rlim_cur... configure: error: unable to determine sizeof rlim_cur

通过在BIND目录下config.log配置log观察

vim config.log
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}
configure:20435: gcc -o conftest -Wall -Werror -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2  -D__APPLE_USE_RFC_3542  conftest.c -l    pthread  -L/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib -lxml2 -lz -lpthread -licucore -lm >&5
conftest.c:90:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]

在对rlim_cur进行编译检测时,因为打开了-Wall 与 -Werror,导致自检的程序出错,配置失败。
那么如何打开-Werror的编译配置呢?再通过–help观察:
--enable-warn-error turn on -Werror when compiling
需要添加这个配置,不要传入-Werror

./configure CFLAGS="-Wall" --without-openssl --enable-warn-error
配置通过。

查看输出对比

checking st_mtim.tv_nsec... no
checking for type rlim_t... yes
checking for strings.h... (cached) yes

假如刚才的配置通过,对于后续的编译,会产生不可预测的问题,这里检查rlim_t是可用,而刚才的配置检测是no,这个与configure检测有关,有些生成代码检测失败不会退出,只是标注无法使用。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值