最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】cygwin先编译buildroot在Installing kernel headers期间出错:/bin/sh: scripts/basic/fixdep: cannot execute binary file

Buildroot crifan 4623浏览 0评论

【问题】

折腾:

【记录】在Cygwin上用Buildroot为xscale建立交叉工具链

期间,编译出错:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ make
>>>   Installing kernel headers
(cd /home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux-2.6.19.1; \
         /bin/make -j4 ARCH=arm \
                HOSTCC="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /bin/gcc" HOSTCFLAGS="" \
                HOSTCXX="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /bin/g++" \
                INSTALL_HDR_PATH=/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux headers_install; \
        )
make[1]: arm-xscale-linux-gnu-gcc: Command not found
make[1]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux-2.6.19.1'
make[1]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux-2.6.19.1'
  CHK     include/linux/version.h
  HOSTCC  scripts/basic/fixdep
/bin/sh: scripts/basic/fixdep: cannot execute binary file
make[2]: *** [scripts/basic/fixdep] Error 126
make[1]: *** [scripts_basic] Error 2
make[1]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux-2.6.19.1'
make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux/.configured] Error 2

如图:

cygwin buildroot bin sh scripts basic fixdep cannot execute binary file

即:

/bin/sh: scripts/basic/fixdep: cannot execute binary file

【解决过程】

1.这个问题,之前就遇到过:

【已解决】Cygwin下用arm-xscale-linux-gnueabi交叉编译Linux内核在配置时出错:/bin/sh: scripts/basic/fixdep: cannot execute binary file

然后参考自己的办法,去看看:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ ls output/toolchain/linux-2.6.19.1/scripts/basic/fixdep* -lha
-rwxr-xr-x 1 CLi Domänen-Benutzer 9.2K Nov  7  2012 output/toolchain/linux-2.6.19.1/scripts/basic/fixdep*
-rw-r--r-- 1 CLi Domänen-Benutzer 9.4K Oct 17  2012 output/toolchain/linux-2.6.19.1/scripts/basic/fixdep.c
-rwxr-xr-x 1 CLi Domänen-Benutzer  62K Sep 24 17:25 output/toolchain/linux-2.6.19.1/scripts/basic/fixdep.exe*

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ file output/toolchain/linux-2.6.19.1/scripts/basic/fixdep
output/toolchain/linux-2.6.19.1/scripts/basic/fixdep: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ file output/toolchain/linux-2.6.19.1/scripts/basic/fixdep.exe
output/toolchain/linux-2.6.19.1/scripts/basic/fixdep.exe: PE32 executable (console) Intel 80386, for MS Windows

很明显,的确是:

此处想要运行的:

output/toolchain/linux-2.6.19.1/scripts/basic/fixdep

是for linux的。

所以,通过两者改名,是可以的。

但是还是打算想想办法,是否有永久的,一次性的解决办法。

2.这人:

Cygwin编译ARM linux内核

的做法,也是和我类似:

其是删除fixdep,让其运行

scripts/basic/fixdep

自动找到

scripts/basic/fixdep.exe

但是还不是根本解决办法。

3.看了对应的makefile文件:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\toolchain\linux-2.6.19.1\scripts\basic\Makefile

内容是:

###
# Makefile.basic list the most basic programs used during the build process.
# The programs listed herein is what is needed to do the basic stuff,
# such as fix dependency file.
# This initial step is needed to avoid files to be recompiled
# when kernel configuration changes (which is what happens when
# .config is included by main Makefile.
# ---------------------------------------------------------------------------
# fixdep: 	 Used to generate dependency information during build process
# docproc:	 Used in Documentation/docbook

hostprogs-y	:= fixdep docproc
always		:= $(hostprogs-y)

# fixdep is needed to compile other host programs
$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep

想要去修改makefile实现自动的,不生成fixdep,而只生成fixdep.exe。

4.那就需要添加对应的cygwin的检测,但是不知道如何加。

所以去看看能否找到别的参考的makefile。

结果找了半天,发现对于linux的kernel的源码中,

包括各种makefile,kconfig等等,根本就没有关于检测是否是cygwin的事情。

所以,彻底放弃此种修改。

5.所以去重命名fixdep:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ mv output/toolchain/linux-2.6.19.1/scripts/basic/fixdep output/toolchain/linux-2.6.19.1/scripts/basic/fixdep_backup

再去编译,就可以了:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ make
>>>   Installing kernel headers
(cd /home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux-2.6.19.1; \
         /bin/make -j4 ARCH=arm \
                HOSTCC="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /bin/gcc" HOSTCFLAGS="" \
                HOSTCXX="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /bin/g++" \
                INSTALL_HDR_PATH=/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux headers_install; \
        )
make[1]: arm-xscale-linux-gnu-gcc: Command not found
make[1]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux-2.6.19.1'
make[1]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain/linux-2.6.19.1'
  CHK     include/linux/version.h
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/unifdef

如图:

HOSTCC  scripts basic fixdep run ok

 

【总结】

还是Linux内核源码,对于cygwin等支持不够好,所以,此处在cygwin下编译各种Linux下面的东西,

尤其是这个linux内核,会出现:

/bin/sh: scripts/basic/fixdep: cannot execute binary file

的错误的

解决办法:

把对应的

scripts/basic/fixdep

删除掉,或重命名:

mv output/toolchain/linux-2.6.19.1/scripts/basic/fixdep output/toolchain/linux-2.6.19.1/scripts/basic/fixdep_backup

这样调用

scripts/basic/fixdep

时,就可以自动找到,(在cygwin下编译会额外生成的scripts/basic/fixdep.exe)

就可以避免此问题了。

转载请注明:在路上 » 【已解决】cygwin先编译buildroot在Installing kernel headers期间出错:/bin/sh: scripts/basic/fixdep: cannot execute binary file

与本文相关的文章

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.198 seconds, using 22.26MB memory