Crosstool is a set of script tools that build and test different versions of GCC and glibc for those architectures that support glibc. It is also an open-source project, namely http: // kegel.com/crosstool. It is much easier to build a cross-tool chain with crosstool than the preceding step-by-step compilation method. This method is recommended for readers who only need to build a cross-compilation tool chain for their work. Use the crosstool tool to build required resources, as shown in Table 2.2.
Table 2.2 required resources
Installation Package
Crosstool-0.42.tar.gz
Http://kegel.com/crosstool
Linux-2.6.10.tar.gz
Ftp.kernel.org
Binutils-2.15.tar.bz2
Ftp.gnu.org
Gcc-3.3.6.tar.gz
Ftp.gnu.org
Glibc-2.3.2.tar.gz
Ftp.gnu.org
Glibc-linuxthreads-2.3.2.tar.gz
Ftp.gnu.org
Linux-libc-headers-2.6.12.0.tar.bz2
Ftp.gnu.org
1. Prepare resource files
Download the required resource files linux-2.6.10.tar.gz, binutils-2.15.tar.bz21_gcc-3.3.6.tar.gz, glibc-runtime, and Linux-libc-headers-2.6.12.0.tar.bz2 from the Internet. Then place these toolkit files in the newly created/home/Mike/downloads directory and decompress crosstool-0.42.tar.gz in the/home/mikedirectory. The command is as follows:
# Cd/home/Mike
# Tar-xvzf crosstool-0.42.tar.gz
2. Create a script file
Next, you need to create your own compilation script named arm. sh, to simplify the compilation of arm. sh, find a closest script file demo-arm.sh as a template, and then copy the contents of the script to arm. sh, modify arm. sh script:
# Cd crosstool-0.42
# Cp demo-arm.sh arm. Sh
# Vi arm. Sh
The modified arm. Sh script is as follows:
#! /Bin/sh
Set-ex
Tarballs_dir =/home/Mike/downloads # define the storage location of the tool chaincode, including linux-2.6.10.tar.gz, binutils-2.15.tar.bz2#gcc-3.3.6.tar.gz.
Result_top =/opt/crosstool # define the installation directory of the toolchain
Export tarballs_dir result_top
Gcc_languages = "C, C ++" # definitions support C and C ++ languages
Export gcc_ages
# Create the/opt/crosstool directory
Mkdir-p $ result_top
# Compile the tool chain, which takes several hours to complete.
Eval 'cat arm. dat gcc-3.3.6-glibc-2.3.2.dat 'sh all. Sh -- notest
Echo done.
3. Create a configuration file
In the arm. Sh script file, pay attention to the arm. dat and gcc-3.3.6-glibc-2.3.2.dat files, these two files are compiled as crosstool configuration files. The content of the arm. dat file is as follows, which is mainly used to define the configuration file, the name of the compilation tool chain generated, and the compilation options.
Kernelconfig = 'pwd'/arm. config # Kernel configuration
Target = arm-Linux # compiled tool chain name
Target_cflags = "-o" # compilation options
The content of the gcc-3.3.6-glibc-2.3.2.dat file is as follows, which mainly defines the library and the version it defines during the compilation process. If some libraries do not exist during the compilation process, crosstool is automatically downloaded from the relevant website. This tool is relatively intelligent and useful.
Binutils_dir = binutils-2.15
Gcc_dir = gcc-3.3.6
Glibc_dir = glibc-2.3.2
Glibcthreads_filename = glibc-linuxthreads-2.3.2
Linux_dir = linux-2.6.10
Linux_sanitized_header_dir = linux-libc-headers-2.6.12.0
4. Execute the script
After preparing the crosstool script file and configuration file, run the arm. Sh script to compile the cross-compilation tool. Run the following command:
# Cd crosstool-0.42
#./Arm. Sh
After several hours of compilation, a new cross-compilation tool will be generated under the/opt/crosstool/gcc-3.3.6-glibc-2.3.2/ARM-Linux/bin directory, which includes the following:
Arm-linux-addr2line arm-Linux-G ++ arm-Linux-LD arm-Linux-size
Arm-Linux-ar arm-Linux-GCC arm-Linux-nm arm-Linux-strings
Arm-Linux-as arm-linux-gcc-3.3.6 arm-Linux-objcopy arm-Linux-strip
Arm-Linux-C ++ arm-Linux-gccbug arm-Linux-objdump fix-embedded-paths
Arm-Linux-C ++ filt arm-Linux-gcov arm-Linux-ranlib
Arm-Linux-CPP arm-Linux-GPROF arm-Linux-readelf
5. Add Environment Variables
Input export Path =/opt/crosstool/gcc-3.3.6-glibc-2.3.2/ARM-Linux/bin: $ path
Note the following two points:
1: Switch common users during./arm. Sh
2: arm. dat target = arm-Linux. If it is arm-Linux, it is wrong.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/dongliqiang2006/archive/2009/11/16/4815331.aspx