From Fedora Project Wiki
(Created page with "{{lang|en|zh-cn|page=Architectures/ARM/CrossToolchain}} = Fedora/ARM 交叉编译工具链 = The F12 ARM initiative created ARM cross toolchain packages for i386 and x86_64 that...")
 
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 17: Line 17:


== Cross-compiling ARM userland binaries ==
== Cross-compiling ARM userland binaries ==
 
    使用交叉编译器编译一个ARM下的Hello World程序的范例:
To cross-compile the canonical Hello World example for ARM, do:
<pre>
<pre>
$ armv5tel-redhat-linux-gnueabi-gcc -Wall -o hello hello.c
$ armv5tel-redhat-linux-gnueabi-gcc -Wall -o hello hello.c
Line 25: Line 24:


== Cross-compiling ARM kernels ==
== Cross-compiling ARM kernels ==
 
    你也可以使用交叉编译工具链来交叉编译一个ARM架构下的Linux内核,只需要修改在顶层目录下的Makefile文件的以下两行:
You can also use the cross-toolchain to cross-build an ARM Linux kernel, by changing these two lines in the top-level Makefile:
<pre>
<pre>
ARCH            ?= $(SUBARCH)
ARCH            ?= $(SUBARCH)
CROSS_COMPILE  ?=
CROSS_COMPILE  ?=
</pre>
</pre>
to:
    为:
<pre>
<pre>
ARCH            ?= arm
ARCH            ?= arm
CROSS_COMPILE  ?= armv5tel-redhat-linux-gnueabi-
CROSS_COMPILE  ?= armv5tel-redhat-linux-gnueabi-
</pre>
</pre>
and then building your kernel as usual.
    然后像往常一样编译你的内核。

Latest revision as of 12:02, 28 December 2011

Fedora/ARM 交叉编译工具链

The F12 ARM initiative created ARM cross toolchain packages for i386 and x86_64 that are built from the same sources as the Fedora native toolchain packages (binutils, gcc, gdb, glibc.) Right now these are gcc-4.1 vintage.

安装这个工具链到你的Fedora计算机:

# cd /etc/yum.repos.d/
# wget http://ftp.linux.org.uk/pub/linux/arm/fedora/cross/cross.repo
# yum install armv5tel-redhat-linux-gnueabi-gcc

This will install everything necessary to run the C compiler and cross-build ARM libraries and binaries that are entirely binary compatible with the native Fedora/ARM libraries and binaries.

如果你对此感兴趣,可以从这里获得源码包.


Cross-compiling ARM userland binaries

    使用交叉编译器编译一个ARM下的Hello World程序的范例:
$ armv5tel-redhat-linux-gnueabi-gcc -Wall -o hello hello.c
$

Cross-compiling ARM kernels

   你也可以使用交叉编译工具链来交叉编译一个ARM架构下的Linux内核,只需要修改在顶层目录下的Makefile文件的以下两行:
ARCH            ?= $(SUBARCH)
CROSS_COMPILE   ?=
   为:
ARCH            ?= arm
CROSS_COMPILE   ?= armv5tel-redhat-linux-gnueabi-
   然后像往常一样编译你的内核。