Ubuntu9.10 the cross-compiling environment is successfully configured.

Source: Internet
Author: User

Ubuntu9.10 the cross-compiling environment is successfully configured.

Before embedded development, you must first establish a cross-compilation environment, which is a development environment consisting of a set of compilers, connectors, and libc libraries. This article describes the establishment process and operation steps of the embedded cross-compilation environment, hoping to help you build the corresponding cross-compilation environment.

I. Required Software and Hardware Environments

■ Host environment

Create a host environment for the cross-compilation tool chain:

Ubuntu 9.10 ~ Ubuntu8.04

■ Ubuntu 9.10 software environment

Make sure that the following software is installed on your Ubuntu 9.10:

Bison flex build-essential

Install these software packages:

Sudo apt-Get install bison flex build-essential

■ Related software packages

Replace all the following yournames with your usernames in the/home directory.
Preparations:
Required installation package:
Crosstool-0.43.tar.gz can be in http://kegel.com/crosstool/crosstool-0.43.tar.gz
Obtain
Create a folder
Mkdir/home/yourname/downloads can also be used by mkdir ~ /Downloads
Copy crosstool-0.43.tar.gz to the downloads directory (by default, the download is actually performed on the desktop)

In addition, there are some installation packages:
【Binutils-2.16.1.tar.bz2 http://ftp.gnu.org/gnu/binutils/

【Glibc-2.3.2.tar.bz2 http://ftp.gnu.org/gnu/glibc/

【Glibc-linuxthreads-2.3.2.tar.bz2 http://ftp.gnu.org/gnu/glibc/

【Linux-2.6.26.5.tar.bz2 http://ftp.kernel.org/pub/linux/kernel/v2.6/

【Gdb-6.5.tar.bz2] http://ftp.gnu.org/gnu/gdb/

【Gcc-4.1.0.tar.bz2] http://ftp.gnu.org/gnu/gcc/gcc-4.1.1/

【Gcc-3.6.tar.bz2] http://ftp.gnu.org/gnu/gcc/gcc-3.3.6/

These will be automatically downloaded during the installation process, or you can download them in advance and put them under/home/yourname/downloads. However, I suggest you download them in advance, otherwise, the system will download several k files per second in a single thread. You need to modify an object in glibc.

II. Specific steps

1. Modify system configurations

The following are some problems that may be encountered during installation. Please come out in advance, saving you the trouble of compiling for half a day and re-compiling if you find the error. If you want to see these problems, you can directly jump to the following installation process.
1. The following two packages are missing during installation.
Bison
Flex
If you have not installed the package before, download and install it. (If you have forgotten the package name, you can enter bison to check the package. If you have not installed the package, you will be prompted to download the packages for installation. Flex is similar)
Sudo apt-Get install bison
Sudo apt-Get install flex
In addition, an mm4 is needed on the Internet, but I didn't prompt when installing it. It seems that flex is automatically installed when dependency is resolved.

2. another inexplicable error is that the GCC version is too old or not installed, but when you use sudo apt-Get install GCC, you will find that GCC is already the latest version, in fact, this error is because the GCC version is too new. The solution is as follows:
Sudo apt-Get install gcc-4.1
CD/usr/bin
Sudo RM gcc
Ln-s gcc-4.1 gcc

Modify sh version

If you run

Ls-La/bin/sh

If the link is Dash, run the following command:

Sudo dpkg-reconfigure dash

Select No to delete dash

If this parameter is not modified, an error occurs during compilation.

3. the following error occurs during installation:
/Home/xxs/crosstool-0.43/build/arm-arm9tdmi-linux-gnu/gcc-4.1.1-glibc-2.3.2/build-glibc/CSU/version-info.h: 1: 1:
Missing terminating "Character
The system found an error in the version-info.h file when compiling version. O.

The solution is to modify a file.
Decompress glibc-2.3.2.tar.bz2
Locate makefile under the glibc-2.3.2/CSU directory and modify as follows
There are two ECHO records at the end of the file.
Echo
"/" Compiled on a $ OS $ Version System "/
"On
'Date + % Y-% m-% D'. // n /"";;/
Changed:
Echo
"/" Compiled on a $ OS $ Version System "/
"On
'Date + % Y-% m-% D'. // n /"";;/
Echo
"/" Available extensions: // n /"";
Changed:
Echo
"/" Available extensions: // n /""/
Save and re-compress glibc-2.3.2.tar.bz2 to overwrite the original glibc-2.3.2.tar.bz2 in the downloadsdirectory.

To solve some of the above problems, you can start the installation.

2. decompress the software package and enter the directory to view important script files.

$ CD downloads

$ Tar-zxvf crosstool-0.43.tar.gz

$ Crosstool-0.43 CD

There are many. Sh scripts and. dat configuration files in this directory. Each supported processor has its corresponding scripts. If you choose demo-arm.sh is to establish the target cross-compilation tool chain.

Go to the cross directory
CD cross-0.43

Configure crosstool-0.43
[Xxxx @ ctools] $ echo $ home
/Home/xxxx if it is not/home/xxxx, You need to export home =/home/xxxx (XXXX system user name)

[Xxxx @ crosstool-0.43] $ VI demo-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/xxxx/download
Result_top =/home/xxxx/crosstool

Export tarballs_dir result_top
Gcc_ages = "C, C ++"
Export gcc_policages # 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 arm. dat gcc-2.95.3-glibc-2.1.3.dat 'sh all. Sh -- notest
# Eval 'cat arm. dat gcc-2.95.3-glibc-2.2.2.dat 'sh all. Sh -- notest
......
......
# Eval 'cat arm. dat gcc-4.1.0-glibc-2.3.2-tls.dat 'sh all. Sh -- notest
Eval 'cat arm. dat gcc-4.1.0-glibc-2.3.2.dat 'sh all. Sh -- notest echo done. Note: CAT arm. dat gcc-4.1.0-glibc-2.3.2.dat instead of the default gcc-4.1.0-glibc-2.3.6-tls.dat

[Xxxx @ crosstool-0.43] $ VI gcc-4.1.1-glibc-2.3.2.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.26.5

Linux_sanitized_header_dir = linux-libc-headers-2.6.12.0
Glibcthreads_filename = glibc-linuxthreads-2.3.2
Gdb_dir = gdb-6.5 [xxxx @ crosstool-0.43] $ VI arm. dat

Kernelconfig = 'pwd'/arm. config
Target = arm-Linux (this name is the target name, which I think is the default (ARM-unknow-Linux-GNU)
So the modification is too long. After the modification, pay attention to the permission of the relevant directory)

Target_cflags = "-o" [note] the red part is the modify/Add part.
Tarballs_dir: the directory where the source code package of the downloaded tool is stored.
Result_top: directory of the toolchain to be generated. a directory with write permission is required. Otherwise, compilation will fail. [Xxxx @ crosstool-0.43] $./The demo-arm.sh system will start Compilation
All used files (missing files) will be downloaded during compilation:
Binutils-2.16.1
Gcc-3.3.6
Gcc-4.1.1
Glibc-2.3.2
Linux-2.6.26.5
Linux-libc-headers-2.6.12.0
Glibc-linuxthreads-2.3.2
Gdb-6.5 this project takes n hours to modify Environment Variables
After the installation is complete, the default installation directory is the/opt/crosstools/
1. Add Environment Variables
Gedit ~ /. Bashrc
Add the following
If [-D/opt/crosstool/gcc-4.1.0-glibc-2.3.2/ARM-Linux]; then
Path =/opt/crosstool/gcc-4.1.0-glibc-2.3.2/ARM-Linux/bin: $ path
Fi
Add the bin directory of the installed tool to the PATH variable.
Save
2. Source ~ /. Bashrc
3. Restart the terminal.
Then you can test it.
Arm-Linux-gcc
Normally
Arm-Linux-GCC: no input files
Indicates that the program can be used.

8. Restore Our modified System Configuration:

Restore GCC to 4.3

Sudo RM/usr/bin/GCC

Sudo ln-S/usr/bin/gcc-4.3/usr/bin/GCC

Reinstall dash

Sudo dpkg-reconfigure dash

Select Yes to reinstall dash

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.