linux编译出错



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

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

[plain]  view plain  copy
  1. [root@localhost module]# make   
  2. make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules  
  3. make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'  
  4.   
  5.   ERROR: Kernel configuration is invalid.  
  6.          include/linux/autoconf.h or include/config/auto.conf are missing.  
  7.          Run 'make oldconfig && make prepare' on kernel src to fix it.  
  8.   
  9.   
  10.   WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers  
  11.            is missing; modules will have no dependencies and modversions.  
  12.   
  13.   Building modules, stage 2.  
  14. /opt/kangear/kernel/linux-2.6.32.2/scripts/Makefile.modpost:42: include/config/auto.conf: 没有那个文件或目录  
  15. make[2]: *** 没有规则可以创建目标“include/config/auto.conf”。 停止。  
  16. make[1]: *** [modules] 错误 2  
  17. make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'  
  18. make: *** [all] 错误 2  
  19. [root@localhost module]#   
        这种是下载的很干净的内核,配置都没有配置;或是配置了,有.config但是没有make zImage。编译一下,不为用这个zImage,只是为了更好的编译内核模块。

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

[plain]  view plain  copy
  1. [root@localhost linux-2.6.32.2]# make zImage  
  2.   HOSTLD  scripts/kconfig/conf  
  3. scripts/kconfig/conf -s arch/arm/Kconfig  
  4.   CHK     include/linux/version.h  
  5.   UPD     include/linux/version.h  
  6.   Generating include/asm-arm/mach-types.h  
  7.   CHK     include/linux/utsrelease.h  
  8.   UPD     include/linux/utsrelease.h  
  9.   SYMLINK include/asm -> include/asm-arm  
  10.   CC      kernel/bounds.s  
  11.   GEN     include/linux/bounds.h  
  12.   CC      arch/arm/kernel/asm-offsets.s  
  13.   GEN     include/asm/asm-offsets.h  
  14.   CALL    scripts/checksyscalls.sh  
  15.   CC      scripts/mod/empty.o  
  16.   HOSTCC  scripts/mod/mk_elfconfig  
  17.   MKELF   scripts/mod/elfconfig.h  
  18.   HOSTCC  scripts/mod/file2alias.o  
  19.   HOSTCC  scripts/mod/modpost.o  
  20.   HOSTCC  scripts/mod/sumversion.o  
  21.   HOSTLD  scripts/mod/modpost  
  22.   HOSTCC  scripts/kallsyms  
  23.   HOSTCC  scripts/pnmtologo  
  24.   HOSTCC  scripts/conmakehash  
  25.   CC      init/main.o  
  26.   CHK     include/linux/compile.h  
  27.   UPD     include/linux/compile.h  
  28.   CC      init/version.o  
  29. ^Cmake[1]: *** wait: 没有子进程。 停止。  
  30. make[1]: *** 正在等待未完成的任务....  
  31. make[1]: *** wait: 没有子进程。 停止。  
  32. make: *** wait: 没有子进程。 停止。  
  33. make: *** 正在等待未完成的任务....  
  34. make: *** wait: 没有子进程。 停止。  
  35. [root@localhost linux-2.6.32.2]#   
        这里再来make一下:

[plain]  view plain  copy
  1. [root@localhost module]# make  
  2. make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules  
  3. make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'  
  4.   
  5.   WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers  
  6.            is missing; modules will have no dependencies and modversions.  
  7.   
  8.   CC [M]  /root/桌面/kangear/module/hello.o  
  9.   Building modules, stage 2.  
  10.   MODPOST 1 modules  
  11. WARNING: modpost: missing MODULE_LICENSE() in /root/桌面/kangear/module/hello.o  
  12. see include/linux/module.h for more information  
  13.   CC      /root/桌面/kangear/module/hello.mod.o  
  14.   LD [M]  /root/桌面/kangear/module/hello.ko  
  15. make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'  
  16. [root@localhost module]# ls  
  17. hello.c   hello.mod.c  hello.o   modules.order   param  
  18. hello.ko  hello.mod.o  Makefile  Module.symvers  symbol  
  19. [root@localhost module]#   

        注意看hello.ko就出来了。

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

[plain]  view plain  copy
  1. [root@localhost hello]# make  
  2. make -C /opt/kangear/kernel/linux-2.6.32.2 M=/opt/kangear/hello  modules  
  3. make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'  
  4.   
  5.   WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers  
  6.            is missing; modules will have no dependencies and modversions.  
  7.   
  8.   CC [M]  /opt/kangear/hello/hello.o  
  9. /opt/kangear/hello/hello.c:3: error: expected declaration specifiers or '...' before string constant  
  10. /opt/kangear/hello/hello.c:3: warning: data definition has no type or storage class  
  11. /opt/kangear/hello/hello.c:3: warning: type defaults to 'int' in declaration of 'MODULE_LECENSE'  
  12. /opt/kangear/hello/hello.c:3: warning: function declaration isn't a prototype  
  13. /opt/kangear/hello/hello.c:17: error: redefinition of '__inittest'  
  14. /opt/kangear/hello/hello.c:16: note: previous definition of '__inittest' was here  
  15. /opt/kangear/hello/hello.c: In function '__inittest':  
  16. /opt/kangear/hello/hello.c:17: warning: return from incompatible pointer type  
  17. /opt/kangear/hello/hello.c: At top level:  
  18. /opt/kangear/hello/hello.c:17: error: redefinition of 'init_module'  
  19. /opt/kangear/hello/hello.c:16: note: previous definition of 'init_module' was here  
  20. make[2]: *** [/opt/kangear/hello/hello.o] 错误 1  
  21. make[1]: *** [_module_/opt/kangear/hello] 错误 2  
  22. make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'  
  23. make: *** [default] 错误 2  
  24. [root@localhost hello]# make  

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


第三种:模块Makefile语法错误

[plain]  view plain  copy
  1. [root@localhost hello]# make  
  2. make: Nothing to be done for `default'.  
  3. [root@localhost hello]#   
        对应的makefile是命令为:
[plain]  view plain  copy
  1. default:  
  2. make -C $(KERNELDIR) M=$(PWD)  modules  
         make前边应该有一个tab键。或者是make前边是空格而不是tab。

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

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

[plain]  view plain  copy
  1. [root@localhost module]# make   
  2. make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules  
  3. make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'  
  4.   
  5.   ERROR: Kernel configuration is invalid.  
  6.          include/linux/autoconf.h or include/config/auto.conf are missing.  
  7.          Run 'make oldconfig && make prepare' on kernel src to fix it.  
  8.   
  9.   
  10.   WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers  
  11.            is missing; modules will have no dependencies and modversions.  
  12.   
  13.   Building modules, stage 2.  
  14. /opt/kangear/kernel/linux-2.6.32.2/scripts/Makefile.modpost:42: include/config/auto.conf: 没有那个文件或目录  
  15. make[2]: *** 没有规则可以创建目标“include/config/auto.conf”。 停止。  
  16. make[1]: *** [modules] 错误 2  
  17. make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'  
  18. make: *** [all] 错误 2  
  19. [root@localhost module]#   
        这种是下载的很干净的内核,配置都没有配置;或是配置了,有.config但是没有make zImage。编译一下,不为用这个zImage,只是为了更好的编译内核模块。

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

[plain]  view plain  copy
  1. [root@localhost linux-2.6.32.2]# make zImage  
  2.   HOSTLD  scripts/kconfig/conf  
  3. scripts/kconfig/conf -s arch/arm/Kconfig  
  4.   CHK     include/linux/version.h  
  5.   UPD     include/linux/version.h  
  6.   Generating include/asm-arm/mach-types.h  
  7.   CHK     include/linux/utsrelease.h  
  8.   UPD     include/linux/utsrelease.h  
  9.   SYMLINK include/asm -> include/asm-arm  
  10.   CC      kernel/bounds.s  
  11.   GEN     include/linux/bounds.h  
  12.   CC      arch/arm/kernel/asm-offsets.s  
  13.   GEN     include/asm/asm-offsets.h  
  14.   CALL    scripts/checksyscalls.sh  
  15.   CC      scripts/mod/empty.o  
  16.   HOSTCC  scripts/mod/mk_elfconfig  
  17.   MKELF   scripts/mod/elfconfig.h  
  18.   HOSTCC  scripts/mod/file2alias.o  
  19.   HOSTCC  scripts/mod/modpost.o  
  20.   HOSTCC  scripts/mod/sumversion.o  
  21.   HOSTLD  scripts/mod/modpost  
  22.   HOSTCC  scripts/kallsyms  
  23.   HOSTCC  scripts/pnmtologo  
  24.   HOSTCC  scripts/conmakehash  
  25.   CC      init/main.o  
  26.   CHK     include/linux/compile.h  
  27.   UPD     include/linux/compile.h  
  28.   CC      init/version.o  
  29. ^Cmake[1]: *** wait: 没有子进程。 停止。  
  30. make[1]: *** 正在等待未完成的任务....  
  31. make[1]: *** wait: 没有子进程。 停止。  
  32. make: *** wait: 没有子进程。 停止。  
  33. make: *** 正在等待未完成的任务....  
  34. make: *** wait: 没有子进程。 停止。  
  35. [root@localhost linux-2.6.32.2]#   
        这里再来make一下:

[plain]  view plain  copy
  1. [root@localhost module]# make  
  2. make -C /opt/kangear/kernel/linux-2.6.32.2 M=/root/桌面/kangear/module modules  
  3. make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'  
  4.   
  5.   WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers  
  6.            is missing; modules will have no dependencies and modversions.  
  7.   
  8.   CC [M]  /root/桌面/kangear/module/hello.o  
  9.   Building modules, stage 2.  
  10.   MODPOST 1 modules  
  11. WARNING: modpost: missing MODULE_LICENSE() in /root/桌面/kangear/module/hello.o  
  12. see include/linux/module.h for more information  
  13.   CC      /root/桌面/kangear/module/hello.mod.o  
  14.   LD [M]  /root/桌面/kangear/module/hello.ko  
  15. make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'  
  16. [root@localhost module]# ls  
  17. hello.c   hello.mod.c  hello.o   modules.order   param  
  18. hello.ko  hello.mod.o  Makefile  Module.symvers  symbol  
  19. [root@localhost module]#   

        注意看hello.ko就出来了。

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

[plain]  view plain  copy
  1. [root@localhost hello]# make  
  2. make -C /opt/kangear/kernel/linux-2.6.32.2 M=/opt/kangear/hello  modules  
  3. make[1]: Entering directory `/opt/kangear/kernel/linux-2.6.32.2'  
  4.   
  5.   WARNING: Symbol version dump /opt/kangear/kernel/linux-2.6.32.2/Module.symvers  
  6.            is missing; modules will have no dependencies and modversions.  
  7.   
  8.   CC [M]  /opt/kangear/hello/hello.o  
  9. /opt/kangear/hello/hello.c:3: error: expected declaration specifiers or '...' before string constant  
  10. /opt/kangear/hello/hello.c:3: warning: data definition has no type or storage class  
  11. /opt/kangear/hello/hello.c:3: warning: type defaults to 'int' in declaration of 'MODULE_LECENSE'  
  12. /opt/kangear/hello/hello.c:3: warning: function declaration isn't a prototype  
  13. /opt/kangear/hello/hello.c:17: error: redefinition of '__inittest'  
  14. /opt/kangear/hello/hello.c:16: note: previous definition of '__inittest' was here  
  15. /opt/kangear/hello/hello.c: In function '__inittest':  
  16. /opt/kangear/hello/hello.c:17: warning: return from incompatible pointer type  
  17. /opt/kangear/hello/hello.c: At top level:  
  18. /opt/kangear/hello/hello.c:17: error: redefinition of 'init_module'  
  19. /opt/kangear/hello/hello.c:16: note: previous definition of 'init_module' was here  
  20. make[2]: *** [/opt/kangear/hello/hello.o] 错误 1  
  21. make[1]: *** [_module_/opt/kangear/hello] 错误 2  
  22. make[1]: Leaving directory `/opt/kangear/kernel/linux-2.6.32.2'  
  23. make: *** [default] 错误 2  
  24. [root@localhost hello]# make  

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


第三种:模块Makefile语法错误

[plain]  view plain  copy
  1. [root@localhost hello]# make  
  2. make: Nothing to be done for `default'.  
  3. [root@localhost hello]#   
        对应的makefile是命令为:
[plain]  view plain  copy
  1. default:  
  2. make -C $(KERNELDIR) M=$(PWD)  modules  
         make前边应该有一个tab键。或者是make前边是空格而不是tab。

你可能感兴趣的:(linux编译出错)