解决cannot run test program错误

来源:互联网 发布:360安全软件管家 编辑:程序博客网 时间:2024/06/10 01:23

在交叉编译的时候总是使用 :

 

./configure --prefix=/home/install --build=i686 --target=arm-linux --host=arm-linux

 

//等相应交叉编译选项

 

但是在CONFIGURE中有很多的测试程序是不可以在HOST上运行的就会出现:

……

 

checking dynamic linker characteristics... GNU/Linux ld.so

checking how to hardcode library paths into programs... immediate

checking for doxygen... /usr/bin/doxygen

checking sys/inotify.h usability... yes

checking sys/inotify.h presence... yes

checking for sys/inotify.h... yes

checking mcheck.h usability... yes

checking mcheck.h presence... yes

checking for mcheck.h... yes

checking whether sys/inotify.h actually works... configure: error: cannot run test program while cross compiling

See `config.log' for more details.

1、记下出错的地方“checking whether sys/inotify.h”
2、去config.log查看相应的错误详解(我查看config.log没有什么很好的收获,又因为这程序在我的linux系统下可以正常编译通过,只是在交叉编译时出问题,确定为测试程序在HOST上不可运行)
3、查看configure文件发现出错的测试代码:
……
{ echo "$as_me:$LINENO: checking whether sys/inotify.h actually works" >&5
echo $ECHO_N "checking whether sys/inotify.h actually works... $ECHO_C" >&6; }
if test "$cross_compiling" = yes; then
  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
See /`config.log' for more details." >&5
echo "$as_me: error: cannot run test program while cross compiling
See /`config.log' for more details." >&2;}
   { (exit 1); exit 1; }; }
else
  cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h.  */
_ACEOF
……
这里可以直接把then部分删除,把else改为then(就是直接去掉测试部分)
对于有其他内容的测试可通过创建cachefile解决(视具体情况而定)
下面给出创建cachefile的例子:
实际错误:error: cannot run test program while cross compiling
configure文件中的相应代码部分:
……
echo "$as_me:$LINENO: checking abstract socket namespace" >&5 
echo $ECHO_N "checking abstract socket namespace... $ECHO_C" >&6 
if test "${ac_cv_have_abstract_sockets+set}" = set; then 
echo $ECHO_N "(cached) $ECHO_C" >&6 
……
//其中ac_cv_have_abstract_sockets是我们要查找的变量
解决方法:
#echo ac_cv_have_abstract_sockets=yes > mips-linux.cache
/*第二个实例摘自网络*/