您的位置:首页 > 运维架构 > Linux

linux编译出错

2016-06-01 17:05 501 查看
在x86上做出来了,但是在ARM上却出现了很多问题,有内核代码准备的问题,有模块代码问题,也有Makefile的问题。看似不起眼的角色,出了问题也很纠结。

第一种:内核代码没有准备好

[plain] view
plain copy

[root@localhost module]# make

make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules

make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'

ERROR: Kernel configuration is invalid.

include/linux/autoconf.h or include/config/auto.conf are missing.

Run 'make oldconfig && make prepare' on kernel src to fix it.

WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers

is missing; modules will have no dependencies and modversions.

Building modules, stage 2.

/opt/kangear/kernel/linux-2.6.32.2/scripts/Makefile.modpost:42: include/config/auto.conf: 没有那个文件或目录

make[2]: *** 没有规则可以创建目标“include/config/auto.conf”。 停止。

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

make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'

make: *** [all] 错误 2

[root@localhost module]#

这种是下载的很干净的内核,配置都没有配置;或是配置了,有.config但是没有make zImage。编译一下,不为用这个zImage,只是为了更好的编译内核模块。

其实看实质就是找不到auto.conf,这个其实已经有了,就是.config,但是如果不想手动来拷贝可以假装make zImage(如下),这里就可以了,完整的编译一个内核只为了这个一个配置文件,也太浪费了。

[plain] view
plain copy

[root@localhost linux-2.6.32.2]# make zImage

HOSTLD scripts/kconfig/conf

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

CHK include/linux/version.h

UPD include/linux/version.h

Generating include/asm-arm/mach-types.h

CHK include/linux/utsrelease.h

UPD include/linux/utsrelease.h

SYMLINK include/asm -> include/asm-arm

CC kernel/bounds.s

GEN include/linux/bounds.h

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

GEN include/asm/asm-offsets.h

CALL scripts/checksyscalls.sh

CC scripts/mod/empty.o

HOSTCC scripts/mod/mk_elfconfig

MKELF scripts/mod/elfconfig.h

HOSTCC scripts/mod/file2alias.o

HOSTCC scripts/mod/modpost.o

HOSTCC scripts/mod/sumversion.o

HOSTLD scripts/mod/modpost

HOSTCC scripts/kallsyms

HOSTCC scripts/pnmtologo

HOSTCC scripts/conmakehash

CC init/main.o

CHK include/linux/compile.h

UPD include/linux/compile.h

CC init/version.o

^Cmake[1]: *** wait: 没有子进程。 停止。

make[1]: *** 正在等待未完成的任务....

make[1]: *** wait: 没有子进程。 停止。

make: *** wait: 没有子进程。 停止。

make: *** 正在等待未完成的任务....

make: *** wait: 没有子进程。 停止。

[root@localhost linux-2.6.32.2]#

这里再来make一下:

[plain] view
plain copy

[root@localhost module]# make

make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules

make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'

WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers

is missing; modules will have no dependencies and modversions.

CC [M] /root/桌面/kangear/module/hello.o

Building modules, stage 2.

MODPOST 1 modules

WARNING: modpost: missing MODULE_LICENSE() in /root/桌面/kangear/module/hello.o

see include/linux/module.h for more information

CC /root/桌面/kangear/module/hello.mod.o

LD [M] /root/桌面/kangear/module/hello.ko

make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'

[root@localhost module]# ls

hello.c hello.mod.c hello.o modules.order param

hello.ko hello.mod.o Makefile Module.symvers symbol

[root@localhost module]#

注意看hello.ko就出来了。

第二种错误:模块代码有异常

[plain] view
plain copy

[root@localhost hello]# make

make -C /opt/kangear/kernel/linux-2.6.32.2 M=/opt/kangear/hello modules

make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'

WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers

is missing; modules will have no dependencies and modversions.

CC [M] /opt/kangear/hello/hello.o

/opt/kangear/hello/hello.c:3: error: expected declaration specifiers or '...' before string constant

/opt/kangear/hello/hello.c:3: warning: data definition has no type or storage class

/opt/kangear/hello/hello.c:3: warning: type defaults to 'int' in declaration of 'MODULE_LECENSE'

/opt/kangear/hello/hello.c:3: warning: function declaration isn't a prototype

/opt/kangear/hello/hello.c:17: error: redefinition of '__inittest'

/opt/kangear/hello/hello.c:16: note: previous definition of '__inittest' was here

/opt/kangear/hello/hello.c: In function '__inittest':

/opt/kangear/hello/hello.c:17: warning: return from incompatible pointer type

/opt/kangear/hello/hello.c: At top level:

/opt/kangear/hello/hello.c:17: error: redefinition of 'init_module'

/opt/kangear/hello/hello.c:16: note: previous definition of 'init_module' was here

make[2]: *** [/opt/kangear/hello/hello.o] 错误 1

make[1]: *** [_module_/opt/kangear/hello] 错误 2

make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'

make: *** [default] 错误 2

[root@localhost hello]# make

这大多是模块代码的错误,里边有中文相关的一些东西了,一些符号。代码是在博客上拷贝的或者是在win下用ue编辑的,直接拷贝到Linux中就会有这种问题。唯一的办法就是重新打一编代码了。目前还没有找到合适的方法。(语法问题就不提了)

第三种:模块Makefile语法错误

[plain] view
plain copy

[root@localhost hello]# make

make: Nothing to be done for `default'.

[root@localhost hello]#

对应的makefile是命令为:

[plain] view
plain copy

default:

make -C $(KERNELDIR) M=$(PWD) modules

make前边应该有一个tab键。或者是make前边是空格而不是tab。

在x86上做出来了,但是在ARM上却出现了很多问题,有内核代码准备的问题,有模块代码问题,也有Makefile的问题。看似不起眼的角色,出了问题也很纠结。

第一种:内核代码没有准备好

[plain] view
plain copy

[root@localhost module]# make

make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules

make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'

ERROR: Kernel configuration is invalid.

include/linux/autoconf.h or include/config/auto.conf are missing.

Run 'make oldconfig && make prepare' on kernel src to fix it.

WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers

is missing; modules will have no dependencies and modversions.

Building modules, stage 2.

/opt/kangear/kernel/linux-2.6.32.2/scripts/Makefile.modpost:42: include/config/auto.conf: 没有那个文件或目录

make[2]: *** 没有规则可以创建目标“include/config/auto.conf”。 停止。

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

make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'

make: *** [all] 错误 2

[root@localhost module]#

这种是下载的很干净的内核,配置都没有配置;或是配置了,有.config但是没有make zImage。编译一下,不为用这个zImage,只是为了更好的编译内核模块。

其实看实质就是找不到auto.conf,这个其实已经有了,就是.config,但是如果不想手动来拷贝可以假装make zImage(如下),这里就可以了,完整的编译一个内核只为了这个一个配置文件,也太浪费了。

[plain] view
plain copy

[root@localhost linux-2.6.32.2]# make zImage

HOSTLD scripts/kconfig/conf

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

CHK include/linux/version.h

UPD include/linux/version.h

Generating include/asm-arm/mach-types.h

CHK include/linux/utsrelease.h

UPD include/linux/utsrelease.h

SYMLINK include/asm -> include/asm-arm

CC kernel/bounds.s

GEN include/linux/bounds.h

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

GEN include/asm/asm-offsets.h

CALL scripts/checksyscalls.sh

CC scripts/mod/empty.o

HOSTCC scripts/mod/mk_elfconfig

MKELF scripts/mod/elfconfig.h

HOSTCC scripts/mod/file2alias.o

HOSTCC scripts/mod/modpost.o

HOSTCC scripts/mod/sumversion.o

HOSTLD scripts/mod/modpost

HOSTCC scripts/kallsyms

HOSTCC scripts/pnmtologo

HOSTCC scripts/conmakehash

CC init/main.o

CHK include/linux/compile.h

UPD include/linux/compile.h

CC init/version.o

^Cmake[1]: *** wait: 没有子进程。 停止。

make[1]: *** 正在等待未完成的任务....

make[1]: *** wait: 没有子进程。 停止。

make: *** wait: 没有子进程。 停止。

make: *** 正在等待未完成的任务....

make: *** wait: 没有子进程。 停止。

[root@localhost linux-2.6.32.2]#

这里再来make一下:

[plain] view
plain copy

[root@localhost module]# make

make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules

make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'

WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers

is missing; modules will have no dependencies and modversions.

CC [M] /root/桌面/kangear/module/hello.o

Building modules, stage 2.

MODPOST 1 modules

WARNING: modpost: missing MODULE_LICENSE() in /root/桌面/kangear/module/hello.o

see include/linux/module.h for more information

CC /root/桌面/kangear/module/hello.mod.o

LD [M] /root/桌面/kangear/module/hello.ko

make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'

[root@localhost module]# ls

hello.c hello.mod.c hello.o modules.order param

hello.ko hello.mod.o Makefile Module.symvers symbol

[root@localhost module]#

注意看hello.ko就出来了。

第二种错误:模块代码有异常

[plain] view
plain copy

[root@localhost hello]# make

make -C /opt/kangear/kernel/linux-2.6.32.2 M=/opt/kangear/hello modules

make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'

WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers

is missing; modules will have no dependencies and modversions.

CC [M] /opt/kangear/hello/hello.o

/opt/kangear/hello/hello.c:3: error: expected declaration specifiers or '...' before string constant

/opt/kangear/hello/hello.c:3: warning: data definition has no type or storage class

/opt/kangear/hello/hello.c:3: warning: type defaults to 'int' in declaration of 'MODULE_LECENSE'

/opt/kangear/hello/hello.c:3: warning: function declaration isn't a prototype

/opt/kangear/hello/hello.c:17: error: redefinition of '__inittest'

/opt/kangear/hello/hello.c:16: note: previous definition of '__inittest' was here

/opt/kangear/hello/hello.c: In function '__inittest':

/opt/kangear/hello/hello.c:17: warning: return from incompatible pointer type

/opt/kangear/hello/hello.c: At top level:

/opt/kangear/hello/hello.c:17: error: redefinition of 'init_module'

/opt/kangear/hello/hello.c:16: note: previous definition of 'init_module' was here

make[2]: *** [/opt/kangear/hello/hello.o] 错误 1

make[1]: *** [_module_/opt/kangear/hello] 错误 2

make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'

make: *** [default] 错误 2

[root@localhost hello]# make

这大多是模块代码的错误,里边有中文相关的一些东西了,一些符号。代码是在博客上拷贝的或者是在win下用ue编辑的,直接拷贝到Linux中就会有这种问题。唯一的办法就是重新打一编代码了。目前还没有找到合适的方法。(语法问题就不提了)

第三种:模块Makefile语法错误

[plain] view
plain copy

[root@localhost hello]# make

make: Nothing to be done for `default'.

[root@localhost hello]#

对应的makefile是命令为:

[plain] view
plain copy

default:

make -C $(KERNELDIR) M=$(PWD) modules

make前边应该有一个tab键。或者是make前边是空格而不是tab。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: