Build a cross-compiler environment In Debian)

Source: Internet
Author: User
Tags gpg

An important step in embedded development is to build your own cross-compilation environment, that is, compile and generate the Execution code on the target machine on the host machine. For example, on the i386 host
For Linux operating systems, embedded systems such as Linux are installed on the arm board. To develop applications on the board, edit and compile on the host machine (i386, link to generate the target code and then download it to the target machine for execution. The compiler needs to run on the i386 machine, and the generated code is executed on the arm machine, that is, cross compilation.
Compilation requires support for header files and function libraries. The compiler also needs the support of other programs. This complete set of program tools constitute a toolchain. Typical toolchain

This tool, including binutils, GCC, GDB, and glibc., is cumbersome and complex to build from start to end, so many ready-made kits are available. The toolchain Installation File is available on the CD attached to the general development board. Some open-source projects also support toolchain. For example:

Http://www.kegel.com/crosstool/ http://tree.celinuxforum.org/CelfPubWiki/ToolChain
Http://www.emdebian.org/tools/crossdev.html
Http://www.codesourcery.com/gnu_toolchains/arm/faq.html
Http://www.linux-mips.org/wiki/Toolchains#Pre-built.2FBuild_Kits
Debian also has a ready toolchain installation package, and Debian has prepared some practical tools for toolchain.
Use
Apt-Get install toolchain-source *
Install the source code package used to compile and generate the toolchain. After installation, under/usr/src/toolchain
Binutils-2.15.tar.bz2 gcc-3.4.3.tar.bz2 gdb-6.1.tar.bz2
Gpc-20040516.tar.gz newlib.tar.bz2 scripts template. tgz.

Binutils.tar.bz2 gcc.tar.bz2 gdb.tar.bz2 newlib-1.12.0.tar.bz2 patches template-gcc.tgz
You can view the howto under the/usr/share/doc/toolchain-source directory, with detailed installation instructions.
Next, you need to create a temporary directory, such

Mkdir/test/Cross
CD/test/Cross
Tpkg-make arm-Linux
The arm here can be another platform. You can refer to the tpkg-Make description. The result of this command is to generate three directories in the current directory to place the source code,

They are "binutils-arm-xxx, GCC-arm-xx, GDB-arm-XXX ".
Then,

CD/test/Cross/binutils-arm -***
Debuild (../generate Deb package)
Debi (install the generated package)

CD/test/Cross/GCC-arm -***
Debuild
Debi
Remember that this order cannot be reversed, because GCC requires binutils support.
If you are lucky enough to finish it in one breath, you will be taken care of by heaven! Generally, various problems may occur. The root cause is whether the version of other packages is supported or not.

Install libc before generating GCC. Run the following command:
Tpkg_sever = ftp.de.debian.org tpkg-install-libc arm-Linux

The last step to generate debuild for binutils and GCC is to generate a signature. You need to use the private key of GPG or PGP. Take GPG as an example.
GPG -- gen-Key

Generate a pair of public and private keys, and set the user ID to name (comment) <email adress>. For normal signature, modify ***-ARMM-xxx/Debian/changes
Username:

-- Qiaolin (Root) <qiaolinnk@eyou.com> (my example)

After the installation is complete, you can download the hello program provided by Debian for verification.
Apt-Get source hello
CD/usr/src/Hello-xx
Cc =/ARM-Linux-GCC./configure -- Host = arm-Linux
Make-K
File./src/Hello
If the following output is displayed, the installation is successful:
./Src/Hello: Elf 32-bit LSB executable, arm, Version 1 (ARM), for GNU/linux2.2.0, dynamically linked (uses SHARED libs), not stripped

========= The end ================

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.