【问题】
折腾:
【记录】Cygwin下交叉编译Linux内核在配置后去make编译
期间,交叉编译出错:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ make ARCH=arm CROSS_COMPILE=arm-xscale-linux-gnueabi- zImage CHK include/linux/version.h make[1]: `include/asm-arm/mach-types.h' is up to date. CHK include/linux/utsrelease.h HOSTCC scripts/basic/fixdep scripts/basic/fixdep.c: In function ‘parse_config_file’: scripts/basic/fixdep.c:242:4: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/fixdep.c: In function ‘parse_dep_file’: scripts/basic/fixdep.c:319:4: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/fixdep.c: In function ‘traps’: scripts/basic/fixdep.c:371:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] scripts/basic/fixdep.c:373:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] HOSTCC scripts/basic/docproc scripts/basic/docproc.c: In function ‘find_export_symbols’: scripts/basic/docproc.c:188:5: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c:191:5: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c:197:5: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c:200:5: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c: In function ‘singfunc’: scripts/basic/docproc.c:267:17: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c: In function ‘parse_file’: scripts/basic/docproc.c:300:6: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c:305:6: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c:310:6: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c:316:6: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/basic/docproc.c:319:6: warning: array subscript has type ‘char’ [-Wchar-subscripts] HOSTCC scripts/mod/mk_elfconfig MKELF scripts/mod/elfconfig.h HOSTCC scripts/mod/file2alias.o In file included from scripts/mod/file2alias.c:13:0: scripts/mod/modpost.h:36:0: warning: "ELF_R_SYM" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/file2alias.c:13: /usr/include/sys/elf_generic.h:81:0: note: this is the location of the previous definition In file included from scripts/mod/file2alias.c:13:0: scripts/mod/modpost.h:37:0: warning: "ELF_R_TYPE" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/file2alias.c:13: /usr/include/sys/elf_generic.h:82:0: note: this is the location of the previous definition scripts/mod/file2alias.c: In function ‘do_of_entry’: scripts/mod/file2alias.c:365:9: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/mod/file2alias.c: In function ‘do_vio_entry’: scripts/mod/file2alias.c:381:3: warning: array subscript has type ‘char’ [-Wchar-subscripts] HOSTCC scripts/mod/modpost.o In file included from scripts/mod/modpost.c:15:0: scripts/mod/modpost.h:36:0: warning: "ELF_R_SYM" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/modpost.c:15: /usr/include/sys/elf_generic.h:81:0: note: this is the location of the previous definition In file included from scripts/mod/modpost.c:15:0: scripts/mod/modpost.h:37:0: warning: "ELF_R_TYPE" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/modpost.c:15: /usr/include/sys/elf_generic.h:82:0: note: this is the location of the previous definition HOSTCC scripts/mod/sumversion.o In file included from scripts/mod/sumversion.c:10:0: scripts/mod/modpost.h:36:0: warning: "ELF_R_SYM" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/sumversion.c:10: /usr/include/sys/elf_generic.h:81:0: note: this is the location of the previous definition In file included from scripts/mod/sumversion.c:10:0: scripts/mod/modpost.h:37:0: warning: "ELF_R_TYPE" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/sumversion.c:10: /usr/include/sys/elf_generic.h:82:0: note: this is the location of the previous definition scripts/mod/sumversion.c:12:26: fatal error: linux/limits.h: No such file or directory compilation terminated. make[2]: *** [scripts/mod/sumversion.o] Error 1 make[1]: *** [scripts/mod] Error 2 make: *** [scripts] Error 2 CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $
如图:
即:
scripts/mod/sumversion.c:12:26: fatal error: linux/limits.h: No such file or directory |
【解决过程】
1.搜:
cygwin sumversion.c linux/limits.h: No such file or directory
找到:
其是Linux系统,所以安装
1. kernel-headers 2. kernel-devel |
后,就解决问题了。对于我此处没用。
2.参考:
http://lists.openembedded.org/pipermail/openembedded-issues/2008-October.txt
去看了下:
linux-2.6.19.1\scripts\mod\sumversion.c
是:
#include <linux/limits.h>
3.突然想起来了,之前的折腾:
【已解决】Eclipse通过Makefile调用交叉编译器交叉编译C项目出错:Type ‘FILE’ could not be resolved
【已解决】Ubuntu下Eclipse中交叉编译C项目出错:Symbol ‘NULL’ could not be resolved
所以去先看看,当前的PATH中,是否包含对应的,此处Cygwin中的交叉编译器其下对应的那些路径,结果是的确没有:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ echo $PATH /home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/bin:/opt/crosstool-ng/bin:/home/CLi/develop/crosstool-ng/x-tools/armxscalecurl/bin:/usr/local/bin:/usr/bin:/cygdrive/d/tmp/dev_install_root/Python27_x64:/cygdrive/d/tmp/dev_install_root/Python27_x64/Lib/site-packages/PyQt4:/cygdrive/d/tmp/dev_install_root/Perl64/site/bin:/cygdrive/d/tmp/dev_install_root/Perl64/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/d/tmp/WordPress/mysql/mysql-5.5.18/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64/ext:/cygdrive/d/tmp/WordPress/DevRoot/Python27:/cygdrive/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Java/jdk1.7.0_11/bin:/home/CLi/develop/docbook/tools/fop/lib:/home/CLi/develop/docbook/tools/fop:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.1.2/TOK/BIN:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.2.0/TOK/BIN:/cygdrive/d/DevRoot/EmbeddedDevelop/trunk/Research/CLI/FF/FBK/develop/tools/develop-tools:/cygdrive/d/tmp/WordPress/DevRoot/Python27/Scripts:/cygdrive/d/tmp/dev_install_root/PostgreSQL/8.3/bin:/cygdrive/d/tmp/dev_install_root/ant/apache-ant-1.8.4/bin:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/d/DevRoot/IndustrialMobileAutomation/HandheldDataSetter/ANTLR/batchFile:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/d/tmp/tmp_dev_root/android/adt-bundle-windows/sdk/platform-tools:/cygdrive/d/tmp/dev_install_root/Tesseract-OCR:/cygdrive/d/tmp/dev_install_root/jython2.5.3/bin:/cygdrive/d/devinstallroot/gnuarm/bin:/cygdrive/d/tmp/dev_install_root/HTML Help Workshop:/cygdrive/c/Users/CLi/AppData/Roaming/npm:/usr/lib/lapack
3.所以,想办法,把对应的,此处的交叉编译器其下的
sysroot/usr/include
和
sysroot/usr/include/linux
加到此处include路径,或者是PATH中去。
但是加之前,先去确认一下,交叉编译器其下,是否有linux/limits.h::
结果是有的:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ find /home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi -name limits.h /home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/include/c++/4.6.0/tr1/limits.h /home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr/include/limits.h /home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr/include/linux/limits.h /home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/lib/gcc/arm-xscale-linux-gnueabi/4.6.0/include-fixed/limits.h /home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/lib/gcc/arm-xscale-linux-gnueabi/4.6.0/install-tools/include/limits.h
4.再去把对应的路径:
/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr/include
和
/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr/include/linux
加到PATH中。
即修改当前自己的.bashrc,加到PATH中,再source一下使得生效。
然后发现,其实,我此处的,另外的文件夹:
/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17
下,才是我的交叉编译器的正则安装的路径,其下也有对应的limits.h文件:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ find /opt/ crosstool-ng/ gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/ gcc-tools/ CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ find /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/ -name limits.h /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/gcc-first/lib/gcc/arm-xscale-linux-gnu/4.0.4/include/limits.h /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/gcc-first/lib/gcc/arm-xscale-linux-gnu/4.0.4/install-tools/include/limits.h /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/lib/gcc/arm-xscale-linux-gnu/4.0.4/include/limits.h /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/lib/gcc/arm-xscale-linux-gnu/4.0.4/install-tools/include/limits.h /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include/asm/limits.h /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include/limits.h /opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include/linux/limits.h
即路径:
/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include
和
/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include/linux
所以,现在只是添加这两个路径:
#PATH=$HOME/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/bin:/opt/crosstool-ng/bin:$HOME/develop/crosstool-ng/x-tools/armxscalecurl/bin:$PATH PATH=$HOME/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/bin:/opt/crosstool-ng/bin:$HOME/develop/crosstool-ng/x-tools/armxscalecurl/bin:$PATH:/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include:/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include/linux
然后使其生效:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ source ~/.bashrc
重新编译试试,结果错误依旧:
HOSTCC scripts/mod/sumversion.o In file included from scripts/mod/sumversion.c:10:0: scripts/mod/modpost.h:36:0: warning: "ELF_R_SYM" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/sumversion.c:10: /usr/include/sys/elf_generic.h:81:0: note: this is the location of the previous definition In file included from scripts/mod/sumversion.c:10:0: scripts/mod/modpost.h:37:0: warning: "ELF_R_TYPE" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/sumversion.c:10: /usr/include/sys/elf_generic.h:82:0: note: this is the location of the previous definition scripts/mod/sumversion.c:12:26: fatal error: linux/limits.h: No such file or directory compilation terminated. make[2]: *** [scripts/mod/sumversion.o] Error 1 make[1]: *** [scripts/mod] Error 2 make: *** [scripts] Error 2
5.关闭cygwin,重新打开再试试,结果还是同样错误。
所以,接着只能去想办法,把对应的路径,添加到makefile的include中去。
但是没到怎么添加。。。
6.参考:
[ 1553160 ] limits.h and cygwin
去把对应的
linux-2.6.19.1\scripts\mod\sumversion.c
中的:
#include <linux/limits.h>
改为:
//#include <linux/limits.h> #include <limits.h>
然后再试试,结果就可以了:
HOSTCC scripts/mod/modpost.o In file included from scripts/mod/modpost.c:15:0: scripts/mod/modpost.h:36:0: warning: "ELF_R_SYM" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/modpost.c:15: /usr/include/sys/elf_generic.h:81:0: note: this is the location of the previous definition In file included from scripts/mod/modpost.c:15:0: scripts/mod/modpost.h:37:0: warning: "ELF_R_TYPE" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/modpost.c:15: /usr/include/sys/elf_generic.h:82:0: note: this is the location of the previous definition HOSTCC scripts/mod/sumversion.o In file included from scripts/mod/sumversion.c:10:0: scripts/mod/modpost.h:36:0: warning: "ELF_R_SYM" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/sumversion.c:10: /usr/include/sys/elf_generic.h:81:0: note: this is the location of the previous definition In file included from scripts/mod/sumversion.c:10:0: scripts/mod/modpost.h:37:0: warning: "ELF_R_TYPE" redefined [enabled by default] In file included from /usr/include/machine/elf.h:45:0, from /usr/include/elf.h:37, from scripts/mod/modpost.h:10, from scripts/mod/sumversion.c:10: /usr/include/sys/elf_generic.h:82:0: note: this is the location of the previous definition scripts/mod/sumversion.c: In function ‘parse_file’: scripts/mod/sumversion.c:275:3: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/mod/sumversion.c: In function ‘parse_source_files’: scripts/mod/sumversion.c:350:24: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/mod/sumversion.c: In function ‘strip_rcs_crap’: scripts/mod/sumversion.c:477:2: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/mod/sumversion.c:484:2: warning: array subscript has type ‘char’ [-Wchar-subscripts] HOSTLD scripts/mod/modpost
如图:
【总结】
此处,当在Cygwin下交叉编译Linux时,在make zImage时出现:
scripts/mod/sumversion.c:12:26: fatal error: linux/limits.h: No such file or directory |
的错误
原因是:
linux-2.6.19.1\scripts\mod\sumversion.c
中的:
#include <linux/limits.h>
在Linux下可以正常找到的,但是在Cygwin下,找不到。
解决办法是:
把:
linux-2.6.19.1\scripts\mod\sumversion.c
中的:
#include <linux/limits.h>
改为:
//#include <linux/limits.h> #include <limits.h>
即可。
转载请注明:在路上 » 【已解决】Cygwin下交叉编译Linux内核make zImage时出错:scripts/mod/sumversion.c:12:26: fatal error: linux/limits.h: No such file or directory