在做一嵌入式Linux内核编译环境移植,使用交叉编译工具链。有一段开源代码拷到Linux本机(Ubuntu 20.04),然后运行make(带有参数),并带选项 --trace, -d,为了输出更多的makefile中执行的内容和调试信息。发现如下错误:
Prerequisite 'configure' is newer than target 'config.status'.
Must remake target 'config.status'.
Makefile:182: update target 'config.status' due to: configure
./config.status --recheck
Putting child 0x55cacecb8510 (config.status) PID 48814 on the chain.
Live child 0x55cacecb8510 (config.status) PID 48814
running /bin/sh ./configure --build=i686-linux --host=mips-linux --libdir=/home/temp/fredli/Main_OI_b4_PQA/apps/public/lib --with-libssl=/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/ --with-libmatrixssl-prefix=/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/ --without-libintl-prefix --disable-digest --disable-ntlm --disable-largefile --disable-nls --disable-FEATURE --disable-opie CC=mips-linux-uclibc-gcc -mips32r2 -msoft-float build_alias=i686-linux host_alias=mips-linux --no-create --no-recursion
configure: WARNING: unrecognized options: --with-libssl, --without-libintl-prefix, --disable-FEATURE
configure: configuring for GNU Wget 1.11.2
checking build system type... i686-pc-linux-gnu
checking host system type... mips-unknown-linux-gnu
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for mips-linux-gcc... mips-linux-uclibc-gcc -mips32r2 -msoft-float
checking whether the C compiler works... no
configure: error: in `/home/minipc/econet/apps/public/wget-1.11.2':
configure: error: C compiler cannot create executables
See `config.log' for more details
Reaping losing child 0x55cacecb8510 PID 48814
make[1]: *** [Makefile:182: config.status] Error 77
在解读这段输出之前,先梳理一下configure和config.status。
简单来说,config.status是configure运行的一个产物,config.status也是可执行文件,运行后可以生成Makefile等文件。 configure在运行的时候会带有一些参数,这些参数是描述机器和系统类型,如--build=i386-linux, --host=mips-linux, --CC=mips-linux-uclibc-gcc, 也就是编译的环境以及编译出的程序的运行环境。configure上次运行所带有的参数会作为option保存在config.status中。
总结一下,configure负责检查系统,包括执行./configure命令时附带参数的可用性。config.status根据检查的结果来生成其他文件如Makefile, config.h等。
在上面的输出中,我们首先看到系统检测到configure文件比config.status还新,这是不合理的,因为config.status由configure运行产生。我查了一下文件日期,是一样的,都是我拷贝当时的时间,可能在拷贝过程中,config.status比configure早个几毫秒甚至更低。
那么因为系统判断configure要新于config.status,所以触发了
./config.status --recheck
这个命令将调用./configure,并带有上次执行该命令时的参数(即option,记录在config.status中)。从上面可以看到,这部分为:
--build=i686-linux --host=mips-linux --libdir=/home/temp/fredli/Main_OI_b4_PQA/apps/public/lib --with-libssl=/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/ --with-libmatrixssl-prefix=/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/ --without-libintl-prefix --disable-digest --disable-ntlm --disable-largefile --disable-nls --disable-FEATURE --disable-opie CC=mips-linux-uclibc-gcc -mips32r2 -msoft-float build_alias=i686-linux host_alias=mips-linux --no-create --no-recursion
在执行这个过程中,如果出错,则./config.status退出,不更新。如果成功,则更新config.status中的内容,但是不会创建Makefile等文件(--no-create),也不会调用子目录里的configure(--no-recursion)。
但是,我们看到,在执行configure的check过程中出错,核心在这两条:
checking for mips-linux-gcc... mips-linux-uclibc-gcc -mips32r2 -msoft-float
checking whether the C compiler works... no
我们使用的交叉编译工具链,mips-linux-gcc, mips-linux-uclibc-gcc都不对。这可能是开源代码的历史遗留问题,所以需要Porting,需要修改为我们的目标交叉编译工具链。
用vim打开对应的config.status文件,可以看到多处有 mips-linux-uclibc-gcc。
304 ac_cs_version="\
305 config.status
306 configured by ./configure, generated by GNU Autoconf 2.59,
307 with options \"'--build=i686-linux' '--host=mips-linux' '--libdir=/home/temp/fredli/Main_OI_b4_PQA/apps/public/lib' '--with-libssl =/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/' '--with-libmatrixssl-prefix=/home/temp/fredli/Main_OI_b4_PQA/apps/public /wget-1.11.2/' '--without-libintl-prefix' '--disable-digest' '--disable-ntlm' '--disable-largefile' '--disable-nls' '--disable-FEATU RE' '--disable-opie' 'CC=mips-linux-uclibc-gcc -mips32r2 -msoft-float' 'build_alias=i686-linux' 'host_alias=mips-linux'\"
385 if $ac_cs_recheck; then
386 echo "running /bin/sh ./configure " '--build=i686-linux' '--host=mips-linux' '--libdir=/home/temp/fredli/Main_OI_b4_PQA/apps/publi c/lib' '--with-libssl=/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/' '--with-libmatrixssl-prefix=/home/temp/fredli/Main_ OI_b4_PQA/apps/public/wget-1.11.2/' '--without-libintl-prefix' '--disable-digest' '--disable-ntlm' '--disable-largefile' '--disable- nls' '--disable-FEATURE' '--disable-opie' 'CC=mips-linux-uclibc-gcc -mips32r2 -msoft-float' 'build_alias=i686-linux' 'host_alias=mip s-linux' $ac_configure_extra_args " --no-create --no-recursion" >&6
387 exec /bin/sh ./configure '--build=i686-linux' '--host=mips-linux' '--libdir=/home/temp/fredli/Main_OI_b4_PQA/apps/public/lib' '--w ith-libssl=/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/' '--with-libmatrixssl-prefix=/home/temp/fredli/Main_OI_b4_PQA/a pps/public/wget-1.11.2/' '--without-libintl-prefix' '--disable-digest' '--disable-ntlm' '--disable-largefile' '--disable-nls' '--dis able-FEATURE' '--disable-opie' 'CC=mips-linux-uclibc-gcc -mips32r2 -msoft-float' 'build_alias=i686-linux' 'host_alias=mips-linux' $a c_configure_extra_args --no-create --no-recursion
388 fi
502 s,@CC@,mips-linux-uclibc-gcc -mips32r2 -msoft-float,;t t
509 s,@CPP@,mips-linux-uclibc-gcc -mips32r2 -msoft-float -E,;t t
把mips-linux-uclibc-gcc全部换成mipsel-buildroot-linux-gnu-gcc. 即在vim环境下,normal模式下,底部输入如下:
:%s/mips-linux-uclibc-gcc/mipsel-buildroot-linux-gnu-gcc/g
回车,显示5处已替换。
5 substitutions on 5 lines
:wq 保存退出。 同时刷新configure文件,因为只有当configure文件比config.status新的时候,才会启动./config.status --recheck。但是其实configure文件不需要实质性修改,就是修改任一字符,然后恢复,再保存退出就是了。然后用ls -l查看时间,确保configure文件比config.status新。
再对整个工程运行make。输出如下:
295398 Must remake target 'config.status'.
295399 make[1]: Entering directory '/home/minipc/econet/apps/public/wget-1.11.2'
295400 Makefile:182: update target 'config.status' due to: configure
295401 ./config.status --recheck
295402 Putting child 0x55a4f95223a0 (config.status) PID 39126 on the chain.
295403 Live child 0x55a4f95223a0 (config.status) PID 39126
295404 running /bin/sh ./configure --build=i686-linux --host=mips-linux --libdir=/home/temp/fredli/Main_OI_b4_PQA/apps/public/lib --with-libssl=/home/temp/fre dli/Main_OI_b4_PQA/apps/public/wget-1.11.2/ --with-libmatrixssl-prefix=/home/temp/fredli/Main_OI_b4_PQA/apps/public/wget-1.11.2/ --without-libintl-prefi x --disable-digest --disable-ntlm --disable-largefile --disable-nls --disable-FEATURE --disable-opie CC=mipsel-buildroot-linux-gnu-gcc -mips32r2 -msoft- float build_alias=i686-linux host_alias=mips-linux --no-create --no-recursion
295405 configure: WARNING: unrecognized options: --with-libssl, --without-libintl-prefix, --disable-FEATURE
295406 configure: configuring for GNU Wget 1.11.2
295407 checking build system type... i686-pc-linux-gnu
295408 checking host system type... mips-unknown-linux-gnu
295409 checking whether make sets $(MAKE)... yes
295410 checking for a BSD-compatible install... /usr/bin/install -c
295411 checking for mips-linux-gcc... mipsel-buildroot-linux-gnu-gcc -mips32r2 -msoft-float
295412 checking whether the C compiler works... yes
295413 checking for C compiler default output file name... a.out
可以看到这时候CC=mipsel-buildroot-linux-gnu-gcc, check通过。成功后,config.status自我更新,且由于Makefile比config.status老,所以,./config.status调用,产生Makefile等文件,包括其子目录。
295530 configure: creating ./config.status
295531 configure: WARNING: unrecognized options: --with-libssl, --without-libintl-prefix, --disable-FEATURE
295532 Reaping winning child 0x55a4f95223a0 PID 39126
295533 Removing child 0x55a4f95223a0 PID 39126 from chain.
295534 Successfully remade target file 'config.status'.
295535 Finished prerequisites of target file 'Makefile'.
295536 Prerequisite 'Makefile.in' is older than target 'Makefile'.
295537 Prerequisite 'config.status' is newer than target 'Makefile'.
295538 Must remake target 'Makefile'.
295539 Makefile:179: update target 'Makefile' due to: config.status
295540 ./config.status
295541 Putting child 0x55a4f95223a0 (Makefile) PID 41614 on the chain.
295542 Live child 0x55a4f95223a0 (Makefile) PID 41614
295543 config.status: creating Makefile
295544 config.status: WARNING: 'Makefile.in' seems to ignore the --datarootdir setting
295545 config.status: creating src/Makefile
295546 config.status: WARNING: 'src/Makefile.in' seems to ignore the --datarootdir setting
295547 config.status: creating doc/Makefile
295548 config.status: WARNING: 'doc/Makefile.in' seems to ignore the --datarootdir setting
295549 config.status: creating util/Makefile
295550 config.status: creating po/Makefile.in
295551 config.status: creating tests/Makefile
295552 config.status: WARNING: 'tests/Makefile.in' seems to ignore the --datarootdir setting
295553 config.status: creating tests/WgetTest.pm
295554 config.status: creating windows/Makefile
295555 config.status: creating stamp-h
295556 config.status: creating src/config.h
295557 config.status: executing default commands
295558 generating po/POTFILES from ./po/POTFILES.in
295559 creating po/Makefile
295560 Reaping winning child 0x55a4f95223a0 PID 41614
295561 Removing child 0x55a4f95223a0 PID 41614 from chain.
295562 Successfully remade target file 'Makefile'.文章来源:https://www.toymoban.com/news/detail-705379.html
从这里可以看出,这个问题已经解决了。编译通过,相应的有着正确配置的文件生成。 文章来源地址https://www.toymoban.com/news/detail-705379.html
到了这里,关于./config.status --recheck 而发现的error的根因与解决方案的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!