【问题】
折腾:
【记录】Cygwin下用arm-xscale-linux-gnueabi交叉编译Linux内核
期间,解决了:
【已解决】Cygwin下配置Linux内核出错:Makefile:419: *** mixed implicit and normal rules. Stop.
后,又出现错误:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ make whgs_defconfig 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/kconfig/conf.o scripts/kconfig/conf.c: In function ‘strip’: scripts/kconfig/conf.c:45:2: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/kconfig/conf.c:53:2: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/kconfig/conf.c: In function ‘conf_string’: scripts/kconfig/conf.c:174:20: warning: variable ‘help’ set but not used [-Wunused-but-set-variable] scripts/kconfig/conf.c: In function ‘conf_sym’: scripts/kconfig/conf.c:208:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable] scripts/kconfig/conf.c: In function ‘conf_choice’: scripts/kconfig/conf.c:368:4: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/kconfig/conf.c:283:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable] HOSTCC scripts/kconfig/kxgettext.o HOSTCC scripts/kconfig/zconf.tab.o In file included from scripts/kconfig/zconf.tab.c:2340:0: scripts/kconfig/confdata.c: In function ‘conf_expand_value’: scripts/kconfig/confdata.c:57:3: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/kconfig/confdata.c: In function ‘conf_read_simple’: scripts/kconfig/confdata.c:238:6: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/kconfig/confdata.c: In function ‘conf_split_config’: scripts/kconfig/confdata.c:608:4: warning: array subscript has type ‘char’ [-Wchar-subscripts] In file included from scripts/kconfig/zconf.tab.c:2343:0: scripts/kconfig/menu.c: In function ‘menu_add_prop’: scripts/kconfig/menu.c:131:3: warning: array subscript has type ‘char’ [-Wchar-subscripts] scripts/kconfig/menu.c:133:4: warning: array subscript has type ‘char’ [-Wchar-subscripts] In file included from scripts/kconfig/zconf.tab.c:2338:0: scripts/kconfig/zconf.tab.c: At top level: scripts/kconfig/lex.zconf.c:1620:16: warning: ‘input’ defined but not used [-Wunused-function] HOSTLD scripts/kconfig/conf scripts/kconfig/conf.o:conf.c:(.text+0x1f): undefined reference to `libintl_gettext' scripts/kconfig/conf.o:conf.c:(.text+0x33): undefined reference to `libintl_gettext' scripts/kconfig/conf.o:conf.c:(.text+0x47): undefined reference to `libintl_gettext' scripts/kconfig/conf.o:conf.c:(.text+0xd56): undefined reference to `libintl_gettext' /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: scripts/kconfig/conf.o: bad reloc address 0x70 in section `.rdata' /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation collect2: error: ld returned 1 exit status make[1]: *** [scripts/kconfig/conf] Error 1 make: *** [whgs_defconfig] Error 2 CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $
即:
scripts/kconfig/conf.o:conf.c:(.text+0x1f): undefined reference to `libintl_gettext’ |
如图:
【解决过程】
1.看到:
Re: something goes wrong while compiling linux kernel under cygwin
说是需要重新编译gcc等内容。
如果是的话,那岂不是:
极其耗时,那么也就可以放在cygwin下编译linux内核了。
2.参考:
RE: _libintl_gettext missing while building Linux kernel
去尝试打上对应的补丁,看看是否有效:
结果此处的
linux-2.6.19.1\scripts\Makefile.host
和帖子里面的,还不太一样:
帖子里是:
# Create executable from a single .c file # host-csingle -> Executable quiet_cmd_host-csingle = HOSTCC $@ - cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOST_LOADLIBES) -o $@ $< + cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOST_LOADLIBES) \ + $(HOSTLOADLIBES_$(@F)) -o $@ $< $(host-csingle): %: %.c FORCE $(call if_changed_dep,host-csingle)
而自己此处的是:
# Create executable from a single .c file # host-csingle -> Executable quiet_cmd_host-csingle = HOSTCC $@ cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) $(host-csingle): %: %.c FORCE $(call if_changed_dep,host-csingle)
看起来,也不太好改。也不会改。也好像不需要改。
所以暂时不改。
3.再去看看:
kernel\linux-2.6.19.1\scripts\kconfig\Makefile
修改后为:
# =========================================================================== # Local mods. This is for cygwin-hosted builds. Should be harmlessly # superfluous on Linux platforms where libintl functionality is in glibc. #ifeq (${OSTYPE},cygwin) HOST_LOADLIBES := -lintl #endif # =========================================================================== # Kernel configuration targets # These targets are used from top-level makefile
然后再重新配置试试,结果错误依旧:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ make whgs_defconfig 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] HOSTLD scripts/kconfig/conf scripts/kconfig/conf.o:conf.c:(.text+0x1f): undefined reference to `libintl_gettext' scripts/kconfig/conf.o:conf.c:(.text+0x33): undefined reference to `libintl_gettext' scripts/kconfig/conf.o:conf.c:(.text+0x47): undefined reference to `libintl_gettext' scripts/kconfig/conf.o:conf.c:(.text+0xd56): undefined reference to `libintl_gettext' /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: scripts/kconfig/conf.o: bad reloc address 0x70 in section `.rdata' /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation collect2: error: ld returned 1 exit status make[1]: *** [scripts/kconfig/conf] Error 1 make: *** [whgs_defconfig] Error 2
4.参考:
Buildroot compilation errors (libintl) in cygwin.
其好像是,加了上面那个-lintl后,就解决问题了。
而此处我没有解决。
然后看了看makefile,好像是hostcc去编译.o的时候,加上的此库。
所以,重新去clean一下:
CLi@PC-CLI-1 ~/develop/kernel/linux-2.6.19.1 $ make clean
再make一下试试,结果错误依旧。
5.参考:
Re: AW: crosstool 0.37 + gdb build fix for cygwin/windows
中的patch:
然后把makefile改为:
# =========================================================================== # Local mods. This is for cygwin-hosted builds. Should be harmlessly # superfluous on Linux platforms where libintl functionality is in glibc. ifeq (${OSTYPE},cygwin) HOST_LOADLIBES := -lintl endif # =========================================================================== # Kernel configuration targets # These targets are used from top-level makefile
再去编译试试,结果错误依旧。
6.再去改为:
# =========================================================================== # Local mods. This is for cygwin-hosted builds. Should be harmlessly # superfluous on Linux platforms where libintl functionality is in glibc. #ifeq (${OSTYPE},cygwin) #HOST_LOADLIBES := -lintl #endif IS_CYGWIN=$(shell uname | grep -i cygwin > /dev/null 2>&1 && echo yes || echo no) ifeq ($(IS_CYGWIN),yes) HOST_LOADLIBES := -lintl endif # =========================================================================== # Kernel configuration targets # These targets are used from top-level makefile
试试,结果错误依旧。
7.怀疑是否调用到该行了。所以故意改错为:
IS_CYGWIN=$(shell uname | grep -i cygwin > /dev/null 2>&1 && echo yes || echo no) ifeq ($(IS_CYGWIN),yes) HOST_LOADLIBES := -lxxxxx endif
然后运行看看是否出错,结果错误无任何变化,说明根本没有执行到这句。
8.然后把对应的配置,加到合适的位置:
# Use reursively expanded variables so we do not call gcc unless # we really need to do so. (Do not call gcc as part of make mrproper) HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) #ifeq (${OSTYPE},cygwin) #HOST_LOADLIBES := -lintl #endif IS_CYGWIN=$(shell uname | grep -i cygwin > /dev/null 2>&1 && echo yes || echo no) ifeq ($(IS_CYGWIN),yes) HOST_LOADLIBES += -lintl endif HOST_EXTRACFLAGS += -DLOCALE PHONY += $(obj)/dochecklxdialog $(obj)/dochecklxdialog: $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) always := dochecklxdialog
再运行看看效果,然后终于是可以解决此问题了,至少是可以找到对应的库函数了,可以正常ld了。
【总结】
在cygwin下,交叉编译kernel,结果出现:
scripts/kconfig/conf.o:conf.c:(.text+0x1f): undefined reference to `libintl_gettext’ |
的错误的:
原因是:
当是cygwin时,缺少对应的-lintl的库。
解决办法是:
想办法,在makefile中,添加上对应库-lintl即可。
修改:
linux-2.6.19.1\scripts\kconfig\Makefile
改为:
# Use reursively expanded variables so we do not call gcc unless # we really need to do so. (Do not call gcc as part of make mrproper) HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) #ifeq (${OSTYPE},cygwin) #HOST_LOADLIBES := -lintl #endif IS_CYGWIN=$(shell uname | grep -i cygwin > /dev/null 2>&1 && echo yes || echo no) ifeq ($(IS_CYGWIN),yes) HOST_LOADLIBES += -lintl endif HOST_EXTRACFLAGS += -DLOCALE PHONY += $(obj)/dochecklxdialog $(obj)/dochecklxdialog: $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) always := dochecklxdialog
即可。
但是接着又出现,类似于之前的:
的错误:
【已解决】Cygwin下交叉编译内核在配置时出错:scripts/kconfig/conf: scripts/kconfig/conf: cannot execute binary file
转载请注明:在路上 » 【已解决】Cygwin下用arm-xscale-linux-gnueabi交叉编译Linux内核在配置时出错:scripts/kconfig/conf.o:conf.c:(.text+0x1f): undefined reference to `libintl_gettext’