Build a cross-compiling environment in Ubuntu9.04

Source: Internet
Author: User
1. install the Standard C development environment. Because Ubuntu9.04Linux is not installed by default, you need to install it first (if it is already installed, you can skip this step ): $ sudoapt-getinstallgccg ++ libgcc1libg ++ makegdb if the above installation does not work, you can try $ sudoapt-getinstallbuild-essential2. download arm-linux-g

1. Install the Standard C development environment. Because Ubuntu 9.04 Linux is not installed by default, you need to install it first (if it is already installed, you can skip this step ):
$ Sudo apt-get install gcc g ++ libgpc3 libg ++ make gdb
If the installation fails, try again.
$ Sudo apt-get install build-essential

2. Download The arm-linux-gcc-4.3.2.tgz to any directory and enter this folder
$ Sudo tar xvzf arm-linux-gcc-4.3.2.tgz-C/
Note: C is followed by a space and C is in uppercase. It is the first letter of the English word "Change,
Here is how to change the directory.
Run this command to install arm-linux-gcc to the/usr/loca/arm/4.3.2 directory.

3. Modify environment variables and add the PATH of the cross compiler to PATH.
Method 1: Modify the/etc/bash. bashrc file (this file is only applicable to the current user)
$ Sudo gedit/etc/bash. bashrc
Add export PATH = $ PATH:/usr/local/arm/4.3.2/bin
Method 2: Modify the/etc/profile file (this file is a system-level environment variable and is applicable to all users ):
$ Sudo gedit/etc/profile
Add path settings and add the following at the end to save the/etc/profile file:
Export PATH = $ PATH:/usr/local/arm/4.3.2/bin
Method 3: Modify the/etc/environment file
$ Sudo gedit/etc/environment
The original file should be PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games "change it to PATH ="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin: /bin:/usr/games:/usr/local/arm/4.3.2/bin "Save and exit.

4. Make the new environment variable take effect immediately without restarting the computer:
Method 1: $ source/root/. bashrc
Method 2: $ source/etc/profile
The method takes effect immediately.

5. Check whether the PATH is added to the PATH:
$ Echo $ PATH
Display/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: /usr/local/arm/4.3.2/bin indicates that the PATH of the cross compiler has been added to PATH. So far, the cross-compilation environment installation is complete.

6. test whether the installation is successful.
$ Arm-linux-gcc-v
The above command will display the arm-linux-gcc information and version, which is my display information:
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured: /scratch/julian/lite-respin/linux/src/gcc-4.3/configure -- build = i686-pc-linux-gnu -- host = i686-pc-linux-gnu -- target = arm-none-linux-gnueabi -- enable-threads -- disable -libmudflap -- disable-libssp -- disable-libstdcxx-pch -- with-gnu-as -- with-gnu-ld -- enable-versions ages = c, c ++ -- enable-shared -- enable-symvers = gnu -- enable-_ cxa_atexit -- with-pkgversion = 'sourcery G ++ Lite 2008q3-72 '-- with-bugurl = https://support.codesourcery.com/GNUToolchain/ -- Disable-nls -- prefix =/opt/codesourcery -- with-sysroot =/opt/codesourcery/arm-none-linux-gnueabi/libc -- with-build-sysroot =/scratch/ julian/lite-respin/linux/install/arm-none-linux-gnueabi/libc -- with-gmp =/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr -- with-mpfr =/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr -- disable-libgomp -- enable-poison-system-directories -- with-build-time- tools =/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin -- with-build-time-tools =/scratch/julian/lite- respin/linux/install/arm-none-linux-gnueabi/bin
Thread model: posix
Gcc version 4.3.2 (Sourcery G ++ Lite 2008q3-72)

7. Compile the Hello World Program and test the cross tool chain.
Write down the following Hello World Program and save it as hello. c.
# Include
Int main ()
{
Printf ("Hello World! \ N ");
Return 0;
}
Run the following command:
$ Arm-linux-gcc-o hello. c
If there is an error in the source program, there will be a prompt. If there is no prompt, you will be able to download it to the ARM target board and run it! Then you can enter the file hello command to view the type of the generated hello file. Note that the generated executable file can only be run in the ARM system, it cannot run on an X86 PC.

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.