为什么 autoconf 会错误地找到以后不可用的功能? [英] Why does autoconf erroneously find a function which isn't available later?

查看:28
本文介绍了为什么 autoconf 会错误地找到以后不可用的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Linux 系统上,我配置了一个软件包 (llvm),autoconf 找到了 arc4random 函数.这里在配置期间提取输出:

On a Linux system I configured a software package (llvm) and autoconf finds the arc4random function. Here an extraction of the output during configuration:

checking for strerror... yes
checking for strerror_r... yes
checking for setenv... yes
checking for arc4random... yes
checking for strtoll... yes
checking for strtoq... yes
checking for sysconf... yes

配置正常.后来,在构建包时,我收到有关未声明说明符 arc4random 的错误:

Configuring goes fine. Later, when building the package I get an error about an undeclared specifier arc4random:

[removed]/lib/Support/Unix/Process.inc:368:10: error: use of undeclared identifier
      'arc4random'
  return arc4random();
         ^

这里引用的位置:

367 #if defined(HAVE_ARC4RANDOM)
368   return arc4random();
369 #else
370   static int x = (::srand(GetRandomNumberSeed()), 0);
371   (void)x;
372   return ::rand();
373 #endif

它得到了适当的保护,这里是 configure.ac 部分:

It's properly guarded, here the configure.ac piece:

AC_CHECK_FUNCS([strerror strerror_r setenv arc4random ])

看起来一切都很好.我想知道为什么配置过程检测到该功能可用.

Seems all fine. I am wondering why the configure process detected the function to be available.

autoconf (GNU Autoconf) 2.63

autoconf (GNU Autoconf) 2.63

这里是 config.log 的摘录:

configure --prefix=[removed] --host=powerpc64-bgq-linux --disable-terminfo --disable-zlib --enable-targets=powerpc CXX=bgclang++ CXXFLAGS=-O3 -fPIC CC=bgclang CFLAGS=-O3 -fPIC LDFLAGS=-shared

推荐答案

根据 arc4random(3),要使用这个函数,你应该在你的代码中包含并用-lbsd链接>.

这个AC_CHECK_FUNCS([... arc4random ]) 的作用是确保arc4random 存在于你的系统中,然后定义名为HAVE_ARC4RANDOM 的宏code>,但不能保证您的代码正确使用它.

What this AC_CHECK_FUNCS([... arc4random ]) does is to make sure arc4random exists in your system, then define the macro named HAVE_ARC4RANDOM, but it cannot guarantee your code is using it correctly.

这篇关于为什么 autoconf 会错误地找到以后不可用的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆