为什么autoconf错误地找到了以后不可用的功能? [英] Why does autoconf erroneously find a function which isn't available later?
问题描述
在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)
,要使用此功能,您应该在代码中包含<bsd/stdlib.h>
并将其与-lbsd
链接.
此AC_CHECK_FUNCS([... arc4random ])
的作用是确保系统中存在arc4random
,然后定义名为HAVE_ARC4RANDOM
的宏,但不能保证您的代码正确使用了它.
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屋!