![](/img/trans.png)
[英]Why arm-linux-gnueabi-gcc and not arm-none-eabi-gcc when compiling Linux kernel and uBoot?
[英]Error when compiling Linux kernel 3.2 for ARM
我按照本教程编译ARM内核3.2 for ARM并使用QEMU进行模拟:
https://balau82.wordpress.com/2012/03/31/compile-linux-kernel-3-2-for-arm-and-emulate-with-qemu/
我遵循以下步骤:
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.tar.bz2
tar xjf linux-3.2.tar.bz2
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
cd linux-3.2
make vexpress_defconfig
make all
cd ..
arm-linux-gnueabi-gcc -static init.c -o init
echo init|cpio -o --format=newc > initramfs
qemu-system-arm -M vexpress-a9 -kernel linux-3.2/arch/arm/boot/zImage -initrd initramfs -serial stdio -append "console=tty1"
我的问题是当我尝试第7步(make all)时,会出现这个问题:
include/linux/compiler-gcc.h:94:30: fatal error: linux/compiler-gcc5.h: No such file or directory
compilation terminated.
/home/ramy/QEMU_Learn/kernel/linux-3.2/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:985: recipe for target 'prepare0' failed
我正在使用Ubuntu操作系统,而我正在使用Linaro工具链来编译内核。
我还检查了PATH变量,结果如下:
$ printenv | grep PATH
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ramy/gcc-arm-none-eabi-5_3-2016q1/bin
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
您的内核版本(3.2.0)太旧,与使用的gcc(gcc-5)不兼容。 您可以使用gcc-4编译内核,或使用较新的内核版本。
您的内核在linux/compiler-gcc.h
标题中有特殊的包含http://lxr.free-electrons.com/source/include/linux/compiler-gcc.h?v=3.2#L91
91 #define __gcc_header(x) #x
92 #define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
93 #define gcc_header(x) _gcc_header(x)
94 #include gcc_header(__GNUC__)
它将包含不同gcc版本的不同文件( GNUC是gcc的主要版本)。 它支持gcc-3和gcc-4,但不支持gcc-5:
http://lxr.free-electrons.com/source/include/linux/?v=3.2
C file compiler-gcc.h 3705 bytes
C file compiler-gcc3.h 631 bytes
C file compiler-gcc4.h 2073 bytes
C file compiler-intel.h 746 bytes
C file compiler.h 8628 bytes
您可以尝试将compiler-gcc4.h
重写为compiler-gcc5.h
,但您应该了解如何执行此操作。 你可能不只是将gcc4复制到gcc5,会有不正确的宏。
该compiler-gcc5.h
加入只有Linux内核版本3.18: http://lxr.free-electrons.com/source/include/linux/compiler-gcc5.h?v=3.18 (不是3.17 的http:// lxr.free-electrons.com/source/include/linux/compiler-gcc5.h?v=3.17 )
较旧的linaro编译器(在gcc-5之前)是https://releases.linaro.org/components/toolchain/binaries/4.9-2016.02/
根据JJ Hakala的评论,在3.2。*内核的最后一个版本中有编译器-gcc5头文件,3.2.81: https ://www.kernel.org/pub/linux/kernel/v3.0/linux- 3.2.81.tar.gz - 只需将wget命令和tar xjf更改为此版本并重试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.