linux c asm编译错误,编译内核常见错误

一:

invalid option `abi=aapcs-linux'选项错误

scripts/kconfig/conf -s arch/arm/Kconfig

CHK     include/linux/version.h

SYMLINK include/asm-arm/arch -> include/asm-arm/arch-s3c2410

make[1]: `include/asm-arm/mach-types.h' is up to date.

CHK     include/linux/utsrelease.h

CC      arch/arm/kernel/asm-offsets.s

cc1: error: invalid option `abi=aapcs-linux'

make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1

make: *** [prepare0] Error 2

解决方法:

You're building an EABI kernel with an OABI compiler. You can either

turn off the EABI option in your config file (Kernel Features->Use

EABI),or, you can use an EABI toolchain such as the ARM/GNU Linux one

from < recommend the latter, because then you can run Arjan's new images.

上述的关掉EABI选项可以通过测试

二:

drivers/video/console/vgacon.o:987:warning:comparison is always true due to limited range of data type

make[3]:***[drivers/video/console/vgacon.o] error 1

make[2]:***[drivers/video/console2] error 2

make[1]:***[drivers/video1] error 2

make:***[drivers] error 2

解决方法:

在make menuconfig 时选哪个设备驱动的选项进去在选Graphics support ->

console display driver support->

vga text console(不选这个)

再编译就行了!

三:`rtc_lock'未定义错误(未完全解决)

方法:

drivers/built-in.o(.text+0x281e4):drivers/char/nvram.c:350: more undefined references to `rtc_lock' follow

找drivers/char/nvram.c有关的rtc_lock定义,发现2.6.21与以往的kernel不同,于是在包含文件中查找,在

include/linux/mc146818rtc.h中发现了rtc_lock的定义,但是有一个__KERNEL__的条件编译选项,去掉这个条件

编译选项,再make zImage,但是问题好像依然存在,继续在drivers/char/nvram.c中增加这个定义spinlock_t

rtc_lock;再编译,发现编译通过。

四:

make zImage和make xipImage

Kernel configured for XIP (CONFIG_XIP_KERNEL=y)

Only the xipImage target is available in this case

make[1]: *** [arch/arm/boot/zImage] Error 1

make: *** [zImage] Error 2

解决方法:

好象是make menuconfig的时候Boot options--->Kernel Execte-In-Place from

ROM选项问题,去掉这个选项编译通过(如果是make xopImage时則需要将这个选项选上),最终成功编译了make zImage。

五:

出现make:***[.tmp_vmlinux1] Error 1这类错误

解决方法:修改arch/arm/kernel/vmlinux.lds

[arm@localhost linux2.6.14]$

vi arch/arm/kernel/vmlinux.lds

将文件尾2条的ASSERT注释掉(1439行)

/* ASSERT((__proc_info_end __

proc_info_begin), "missing CPU support") */

/* ASSERT((__arch_info_end __

arch_info_begin), "no machine record defined") */

然后重新make zImage即可

六:

如果大家遇到一下几个问题可以参考本文:

a      make menuconfig

1)     /usr/bin/ld: cannot find -lncurses

解决办法:

sudo apt-get install libncurses5-dev

2)     Your display is too small to run Menuconfig!

解决办法:     窗口最大化

b

/usr/local/arm/bin/arm-linux-ld:arch/arm/kernel/vmlinux.lds:782: parse error

make: *** [.tmp_vmlinux1] 错误 1

ld链接时产生错误

对应行:

/home/kevin/ARMSystem/linux-2.6.12/arch/arm/kernel/vmlinux.lds

/* those must never be empty */

ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")

ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")

解决办法: 注释掉这两行

下面是编译时产生的一些信息

1' cross compile

# CROSS_COMPILE specify the prefix used for all executables used

# during compilation. Only gcc and related bin-utils executables

# are prefixed with $(CROSS_COMPILE).

# CROSS_COMPILE can be set on the command line

# make CROSS_COMPILE=ia64-linux-

# Alternatively CROSS_COMPILE can be set in the environment.

# Default value for CROSS_COMPILE is not to prefix executables

# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile

ARCH         := arm

CROSS_COMPILE     := /usr/local/arm/bin/arm-linux-

2'

kevin@kevin-desktop:~/ARMSystem/linux-2.6.12$ make distclean

# distclean

#

.PHONY: distclean

distclean: mrproper

@find $(srctree) $(RCS_FIND_IGNORE) \

\( -name '*.orig' -o -name '*.rej' -o -name '*~' \

-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \

-o -name '.*.rej' -o -size 0 \

-o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \

-type f -print | xargs rm -f

只是找到一些残存文件并删除;

3‘

kevin@kevin-desktop:~/ARMSystem/linux-2.6.12$ make menuconfig

HOSTCC   scripts/basic/fixdep

scripts/basic/fixdep.c: 在函数‘parse_config_file’中:

scripts/basic/fixdep.c:245: 警告: 传递参数 1 (属于‘use_config’) 给指针时,目标与指针符号不一致

scripts/basic/fixdep.c: 在函数‘parse_dep_file’中:

scripts/basic/fixdep.c:299: 警告: 传递参数 1 (属于‘__builtin_strchr’) 给指针时,目标与指针符号不一致

scripts/basic/fixdep.c:299: 警告: 对指针赋值时目标与指针符号不一致

HOSTCC   scripts/basic/split-include

scripts/basic/split-include.c: 在函数‘main’中:

scripts/basic/split-include.c:113: 警告: 对指针赋值时目标与指针符号不一致

HOSTCC   scripts/basic/docproc

scripts/basic/docproc.c: 在函数‘find_export_symbols’中:

scripts/basic/docproc.c:184: 警告: 对指针赋值时目标与指针符号不一致

scripts/basic/docproc.c:185: 警告: 对指针赋值时目标与指针符号不一致

scripts/basic/docproc.c:202: 警告: 传递参数 2 (属于‘add_new_symbol’) 给指针时,目标与指针符号不一致

scripts/basic/docproc.c: 在函数‘singfunc’中:

scripts/basic/docproc.c:274: 警告: 对指针赋值时目标与指针符号不一致

scripts/basic/docproc.c: 在函数‘parse_file’中:

scripts/basic/docproc.c:296: 警告: 对指针赋值时目标与指针符号不一致

SHIPPED scripts/kconfig/zconf.tab.h

HOSTCC   scripts/kconfig/conf.o

scripts/kconfig/conf.c: 在函数‘strip’中:

scripts/kconfig/conf.c:46: 警告: 传递参数 1 (属于‘strlen’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c: 在函数‘conf_askvalue’中:

scripts/kconfig/conf.c:94: 警告: 传递参数 1 (属于‘fgets’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c: 在函数‘conf_string’中:

scripts/kconfig/conf.c:187: 警告: 传递参数 1 (属于‘strlen’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:188: 警告: 对指针赋值时目标与指针符号不一致

scripts/kconfig/conf.c: 在函数‘conf_sym’中:

scripts/kconfig/conf.c:236: 警告: 传递参数 1 (属于‘strlen’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:236: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:236: 警告: 传递参数 1 (属于‘strlen’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:236: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:236: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:236: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:248: 警告: 传递参数 1 (属于‘strlen’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:248: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:248: 警告: 传递参数 1 (属于‘strlen’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:248: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:248: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:248: 警告: 传递参数 1 (属于‘__builtin_strcmp’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c: 在函数‘conf_choice’中:

scripts/kconfig/conf.c:350: 警告: 传递参数 1 (属于‘fgets’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:360: 警告: 传递参数 1 (属于‘atoi’) 给指针时,目标与指针符号不一致

scripts/kconfig/conf.c:384: 警告: 传递参数 1 (属于‘strlen’) 给指针时,目标与指针符号不一致

HOSTCC   scripts/kconfig/kxgettext.o

HOSTCC   scripts/kconfig/mconf.o

scripts/kconfig/mconf.c: 在函数‘cprint1’中:

scripts/kconfig/mconf.c:337: 警告: 对指针赋值时目标与指针符号不一致

scripts/kconfig/mconf.c:339: 警告: 传递参数 1 (属于‘vsprintf’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c: 在函数‘cprint’中:

scripts/kconfig/mconf.c:357: 警告: 对指针赋值时目标与指针符号不一致

scripts/kconfig/mconf.c:359: 警告: 传递参数 1 (属于‘vsprintf’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c: 在函数‘search_conf’中:

scripts/kconfig/mconf.c:550: 警告: 传递参数 1 (属于‘sym_re_search’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c: 在函数‘conf’中:

scripts/kconfig/mconf.c:761: 警告: 传递参数 2 (属于‘strcpy’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c:765: 警告: 传递参数 1 (属于‘sscanf’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c: 在函数‘conf_choice’中:

scripts/kconfig/mconf.c:915: 警告: 传递参数 1 (属于‘sscanf’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c:920: 警告: 传递参数 1 (属于‘sscanf’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c: 在函数‘conf_string’中:

scripts/kconfig/mconf.c:961: 警告: 传递参数 2 (属于‘sym_set_string_value’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c: 在函数‘conf_load’中:

scripts/kconfig/mconf.c:990: 警告: 传递参数 1 (属于‘conf_read’) 给指针时,目标与指针符号不一致

scripts/kconfig/mconf.c: 在函数‘conf_save’中:

scripts/kconfig/mconf.c:1019: 警告: 传递参数 1 (属于‘conf_write’) 给指针时,目标与指针符号不一致

SHIPPED scripts/kconfig/zconf.tab.c

SHIPPED scripts/kconfig/lex.zconf.c

HOSTCC   scripts/kconfig/zconf.tab.o

In file included from scripts/kconfig/zconf.tab.c:2125:

scripts/kconfig/confdata.c: 在函数‘conf_expand_value’中:

scripts/kconfig/confdata.c:39: 警告: 传递参数 1 (属于‘__builtin_strchr’) 给指针时,目标与指针符号不一致

scripts/kconfig/confdata.c:39: 警告: 对指针赋值时目标与指针符号不一致

scripts/kconfig/confdata.c:40: 警告: 传递参数 2 (属于‘__builtin_strncat’) 给指针时,目标与指针符号不一致

scripts/kconfig/confdata.c:51: 警告: 传递参数 2 (属于‘strcat’) 给指针时,目标与指针符号不一致

scripts/kconfig/confdata.c: 在函数‘conf_get_default_confname’中:

scripts/kconfig/confdata.c:62: 警告: 传递参数 1 (属于‘conf_expand_value’) 给指针时,目标与指针符号不一致

scripts/kconfig/confdata.c: 在函数‘conf_read’中:

scripts/kconfig/confdata.c:88: 警告: 传递参数 1 (属于‘conf_expand_value’) 给指针时,目标与指针符号不一致

HOSTLD   scripts/kconfig/mconf

/usr/bin/ld: cannot find -lncurses

collect2: ld 返回 1

-e

>> Unable to find the Ncurses libraries.

>>

>> You must install ncurses-devel in order

>> to use 'make menuconfig'

make[2]: *** [scripts/lxdialog/ncurses] 错误 1

make[1]: *** [menuconfig] 错误 2

make: *** [menuconfig] 错误 2

分析, make menuconfig 机制

linux内核配置界面

make

config是有问必答的方式,每个内核选项它都会问你要、不要、模块,选错了一个就必须从头再来一遍;make

menuconfig提供一个基于文本的图形界面,它依赖于ncurses5这个包,键盘操作,可以修改选项,一般推荐用这个;make

xconfig需要你有x window

system支持,就是说你要在KDE、GNOME之类的X桌面环境下才可用,好处是支持鼠标,坏处是X本身占用系统周期,而且X环境容易引起编译器的不

稳定

缺少相应的文件

kevin@kevin-desktop:~/ARMSystem/linux-2.6.12$ dpkg -l |grep ncurses

ii   libncurses5                                 5.6+20071124-1ubuntu2          Shared libraries for terminal handling

ii   libncursesw5                                5.6+20071124-1ubuntu2          Shared libraries for terminal handling (wide

ii   mtr-tiny                                    0.72-2ubuntu1                  Full screen ncurses traceroute tool

ii   ncurses-base                                5.6+20071124-1ubuntu2          Descriptions of common terminal types

ii   ncurses-bin                                 5.6+20071124-1ubuntu2          Terminal-related programs and man pages

kevin@kevin-desktop:~/ARMSystem/linux-2.6.12/scripts$ find . -type f |xargs grep [N,n]curses

./lxdialog/dialog.h: * Colors in ncurses 1.9.9e do not work properly since foreground and

./lxdialog/dialog.h: * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible

./lxdialog/Makefile:HOST_LOADLIBES    := -lncurses

./lxdialog/Makefile:ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))

./lxdialog/Makefile:         HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC=""

./lxdialog/Makefile:ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))

./lxdialog/Makefile:         HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC=""

./lxdialog/Makefile:ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))

./lxdialog/Makefile:         HOST_EXTRACFLAGS += -DCURSES_LOC=""

./lxdialog/Makefile:always         := ncurses $(hostprogs-y)

./lxdialog/Makefile:.PHONY: $(obj)/ncurses

./lxdialog/Makefile:$(obj)/ncurses:

./lxdialog/Makefile:         echo ">> Unable to find the Ncurses libraries." ;\

./lxdialog/Makefile:         echo ">> You must install ncurses-devel in order" ;\

二进制文件 ./kconfig/mconf 匹配

二进制文件 ./kconfig/mconf.o 匹配

./kconfig/mconf.c:"export those variables via /etc/profile.   Some ncurses programs can\n"

在文件中调用:

.PHONY: $(obj)/ncurses

$(obj)/ncurses:

@echo "main() {}" > lxtemp.c

@if $(HOSTCC) lxtemp.c   $(HOST_LOADLIBES); then \

rm -f lxtemp.c a.out; \

else \

rm -f lxtemp.c; \

echo -e "\007" ;\

echo ">> Unable to find the Ncurses libraries." ;\

echo ">>" ;\

echo ">> You must install ncurses-devel in order" ;\

HOST_LOADLIBES    := -lncurses

sudo apt-get install libncurses5-dev

继续

scripts/lxdialog/lxdialog.c:211: 警告: 传递参数 2 (属于‘fprintf’) 给指针时,目标与指针符号不一致

HOSTCC   scripts/lxdialog/menubox.o

HOSTCC   scripts/lxdialog/msgbox.o

HOSTCC   scripts/lxdialog/textbox.o

HOSTCC   scripts/lxdialog/util.o

HOSTCC   scripts/lxdialog/yesno.o

HOSTLD   scripts/lxdialog/lxdialog

scripts/kconfig/mconf arch/arm/Kconfig

drivers/char/Kconfig:587: can't open file "drivers/char/watchdog/Kconfig" '

make[1]: *** [menuconfig] 错误 1

make: *** [menuconfig] 错误 2

重新解压

kevin@kevin-desktop:~/ARMSystem/linux-2.6.12$ make menuconfig

scripts/kconfig/mconf arch/arm/Kconfig

#

# using defaults found in .config

#

Your display is too small to run Menuconfig!

It must be at least 19 lines by 80 columns.

make[1]: *** [menuconfig] 错误 1

make: *** [menuconfig] 错误 2

呵呵,原来窗口需要最大化

导入配置文件

make zImage

kevin@kevin-desktop:~/ARMSystem/linux-2.6.12$ make zImage

CHK      include/linux/version.h

make[1]: “arch/arm/kernel/asm-offsets.s”是最新的。

make[1]: “include/asm-arm/mach-types.h”是最新的。

CHK      include/linux/compile.h

CHK      usr/initramfs_list

GEN      .version

CHK      include/linux/compile.h

UPD      include/linux/compile.h

CC       init/version.o

LD       init/built-in.o

LD       .tmp_vmlinux1

/usr/local/arm/bin/arm-linux-ld:arch/arm/kernel/vmlinux.lds:782: parse error

make: *** [.tmp_vmlinux1] 错误 1

ld链接时产生错误

对应行:

/home/kevin/ARMSystem/linux-2.6.12/arch/arm/kernel/vmlinux.lds

/* those must never be empty */

ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")

ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")

ld用法:

For the moment, I recommend commenting out those lines, and checking

manually that you have proc and arch info in your final vmlinux image.

注视掉这两行;

kevin@kevin-desktop:~/ARMSystem/linux-2.6.12$ make zImage

CHK      include/linux/version.h

make[1]: “arch/arm/kernel/asm-offsets.s”是最新的。

make[1]: “include/asm-arm/mach-types.h”是最新的。

CHK      include/linux/compile.h

CHK      usr/initramfs_list

GEN      .version

CHK      include/linux/compile.h

UPD      include/linux/compile.h

CC       init/version.o

LD       init/built-in.o

LD       .tmp_vmlinux1

KSYM     .tmp_kallsyms1.S

AS       .tmp_kallsyms1.o

LD       .tmp_vmlinux2

KSYM     .tmp_kallsyms2.S

AS       .tmp_kallsyms2.o

LD       vmlinux

SYSMAP   System.map

SYSMAP   .tmp_System.map

OBJCOPY arch/arm/boot/Image

Kernel: arch/arm/boot/Image is ready

AS       arch/arm/boot/compressed/head.o

GZIP     arch/arm/boot/compressed/piggy.gz

AS       arch/arm/boot/compressed/piggy.o

CC       arch/arm/boot/compressed/misc.o

In file included from include/asm/arch/uncompress.h:29,

from arch/arm/boot/compressed/misc.c:23:

include/asm/arch/regs-gpio.h:856:29: warning: no newline at end of file

LD       arch/arm/boot/compressed/vmlinux

OBJCOPY arch/arm/boot/zImage

Kernel: arch/arm/boot/zImage is ready

内核编译成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值