Use crosstool 0.43 to create an arm cross compiler Arm-Linux-GCC on Ubuntu

Source: Internet
Author: User

I. Ensure that the following software packages are installed on Ubuntu

Bison
Flex
Build-essential
Patch
Libncurses5-dev

View the dependency of the software package. You can see the following:

$ Apt-Cache depends build-essential

Install the package using $ sudo apt-Get install package name

II. Crosstool

Crosstool
Is a set of script tools that can build and test different versions of GCC and glibc for those architectures that support glibc. It is also an open-source project, which is http:
// Kegel.com/crosstool. It is much easier to build a cross tool chain with crosstool than to compile it in a step.
Readers of the compilation tool chain suggest using this method. Use the crosstool tool to build the required resources, as shown in.

Table 2.2 required resources

Installation Package

Crosstool-0.43.tar.gz
Http://kegel.com/crosstool

Linux-2.6.15.4.tar.gz
Ftp.kernel.org

Binutils-2.16.1.tar.bz2
Ftp.gnu.org

Gcc-3.3.6.tar.gz
Ftp.gnu.org

Gcc-4.1.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

Gdb6.5.tar.bz2

3. Crosstoo Installation Steps

1. Prepare resource files

First, download the required resource files from the Internet, put these toolkit files under the newly created $ home/downloads directory, and then decompress crosstool-0.43.tar.gz in the $ home/downloadsdirectory. The command is as follows:

# Cd/home/zhoug/downloads (note $ home =/home/zhoug)

# Tar-xzvf crosstool-0.42.tar.gz

(

For the tar.bz2 file, decompress the command

# Tar-xjvf xxx.tar.bz2

)

2. Create a script file

# Cd home/downloads/crosstool0.43

# Cp demo-arm9tdmi.sh arm. Sh

# Sudo gedit arm. Sh

#! /Bin/sh
# This script has one line for each known working toolchain
# For this architecture. uncomment the one you want.
# Generated by generate-demo.pl from buildlogs/all.dats.txt

Set-ex
Tarballs_dir = $ home/downloads # resource download directory
Result_top =/opt/crosstool # The final directory generated by the compilation tool
Export tarballs_dir result_top
Gcc_languages = "C, C ++" # definitions support C and C ++ languages
Export gcc_ages

# Really, you shoshould do the mkdir before running this,
# And chown/opt/crosstool to yourself so you don't need to run as root.
Mkdir-p $ result_top

# Eval 'cat arm9tdmi. dat gcc-3.2.3-glibc-2.2.5.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.2.3-glibc-2.3.2.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.2.3-glibc-2.3.2-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.3.6-glibc-2.2.5.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.3.6-glibc-2.3.2.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.3.6-glibc-2.3.2-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.4.5-glibc-2.2.5.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.4.5-glibc-2.3.2.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.4.5-glibc-2.3.2-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.4.5-glibc-2.3.5.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.4.5-glibc-2.3.5-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.4.5-glibc-2.3.6.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-3.4.5-glibc-2.3.6-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-4.0.2-glibc-2.3.2.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-4.0.2-glibc-2.3.2-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-4.0.2-glibc-2.3.5.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-4.0.2-glibc-2.3.5-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-4.0.2-glibc-2.3.6.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-4.0.2-glibc-2.3.6-tls.dat 'sh all. Sh -- notest
# Eval 'cat arm9tdmi. dat gcc-4.1.0-glibc-2.3.2.dat 'sh all. Sh -- notest
Eval 'cat arm9tdmi. dat gcc-4.1.0-glibc-2.3.2-tls.dat 'sh all. Sh -- notest -- nounpack

Echo done

3. Create a configuration file

# Gedit arm9tdmi. dat

Bytes ----------------------------------------------------------------------------------------------------------

Kernelconfig = 'pwd'/arm. config
Target = arm-Linux # compiled tool chain name
Gcc_extra_config = "-- with-CPU = arm9tdmi -- enable-cxx-flags =-mcpu = arm9tdmi"
Target_cflags = "-o"

Bytes ----------------------------------------------------------------------------------------------------------

# Gedit gcc-4.1.0-glibc-2.3.2-tls.dat

Binutils_dir = binutils-2.16.1
Gcc_core_dir = gcc-3.3.6
Gcc_dir = gcc-4.1.0
Glibc_dir = glibc-2.3.2
Linux_dir = linux-2.6.15.4
Linux_sanitized_header_dir = linux-libc-headers-2.6.12.0
Glibcthreads_filename = glibc-linuxthreads-2.3.2
Gdb_dir = gdb-6.5
Glibc_extra_config = "$ glibc_extra_config -- With-TLS -- With-_ thread -- enable-kernel = 2.4.18"

Bytes ----------------------------------------------------------------------------------------------------------

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.43

#./Arm. Sh

5. Set Environment Variables

# Sudo gedit/etc/bash. bashrc

Export Path = $ path:/opt/crosstool/gcc-4.1.0-glibc-2.3.2/ARM-Linux/bin:

4. Compilation errors

1. The GCC version on my machine is GCC 4.3.3, and an error occurs during compilation.

GCC version high or low, sudo apt-Get remove GCC, sudo apt-Get install gcc-4.1. Because ubuntu can install multiple versions of GCC, I only execute

Sudo apt-Get install gcc-4.1.

After installing gcc-4.1

Sudo RM/usr/bin/GCC (delete GCC, it's just a soft connection file to the gcc-4.3.2)
Sudo ln-S/usr/bin/gcc-4.1/usr/bin/GCC (build a soft connection from GCC to gcc-4.1)

2. The error is as follows:

Make [2]: *** [/home/zhoug/downloads/crosstool-0.43/build/ARM-Linux/gcc-4.1.0-glibc-2.3.2/build-glibc/CSU/version. O] Error 1
Bash: Make [2]: The command cannot be found.
Make [2]: Leaving directory '/home/zhoug/downloads/crosstool-0.43/build/ARM-Linux/gcc-4.1.0-glibc-2.3.2/CSU'
Make [1]: *** [CSU/subdir_lib] Error 2
Make [1]: Leaving directory '/home/zhoug/downloads/crosstool-0.43/build/ARM-Linux/gcc-4.1.0-glibc

Solution:

Modify the following file:
Gedit/crosstool0.43/build/ARM/Linux/gcc-4.1.0-glibc-2.3.2/build-glibc/CSU/version-info.h
"Available extensions:/N"
"/N"
Vim Demo-arm.sh.
Add -- notest -- nounpack after the tool chain version

3. Other online errors

1) "Install GCC" after installing the gcc-4.1, re-compile. Have you thought about this ?! No, the following error occurs:
In file already ded from version. C: 33:
/Home/tekkaman/working/crosstool-0.43/build/arm-9tdmi-linux-gnu/gcc-4.1.1-glibc-2.3.2/build-glibc/CSU/version-info.h: 2: 1:
Missing terminating "Character
/Home/tekkaman/working/crosstool-0.43/build/arm-9tdmi-linux-gnu/gcc-4.1.1-glibc-2.3.2/build-glibc/CSU/version-info.h: 3: 1:
Missing terminating "Character
Google found that Ubuntu set the system's default shell to dash (the Debian almqualified shell), so the file format generated by the script is different from that generated by bash, resulting in compilation errors. In use
Ursa
.
Sudo mV/bin/sh. Old
Sudo ln-SF bash/bin/sh

2) An error was reported when Skyeye was compiled today.
/Usr/include/bits/fcntl2.h: 51: Error: Call '_ open_missing_mode'. The declared error attribute: open with o_creat in second argument needs 3 arguments
It can be compiled in ora 10. It should be okay in Ubuntu, but this problem occurs. Quickly follow up. First, compare the two versions of/usr/include/bits/fcntl2.h, and find that there is no difference, that is, the code problem. Code change. The error message is in line 1.
If (! NF-> writebuffer)
Free (NF-> writebuffer );
Free (NF );
The error message is "Open", but the first row is "free". If you comment out the first two rows, the false positive is "free (NF)". Continue to comment out "free (NF)". Finally, the error is given, yes
If (NF-> fdump = open (Dev-> dump, file_flag) 0) of the 519 rows)
Open has only two parameters. Add a 0777 parameter and the code is (if (NF-> fdump = open (Dev-> dump, file_flag, 0777) 0)
Thank God. The compilation is successful.

Arm-Linux-ar Stack Overflow

It is mainly about the 4.3.2 compiler. Change it to the 4.1 compiler.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/public/archive/2010/03/06/5352598.aspx

Related Article

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.