Ubuntu cross-compiling environment

Source: Internet
Author: User

1. Install the Standard C development environment. Because Linux is not installed by default, you need to install it first (if it has been installed, you can skip this step ): # Sudo apt-Get install GCC g ++ libgpc3 libg ++ make GDB
2. Download arm-linux-gcc-3.4.1.tar.bz2 to any directory, and I downloaded it to my personal folder/home/WRQ arm-linux-gcc-3.4.1.tar.bz2 as follows: Http://www.handhelds.org/download/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2
3. Unzip the arm-linux-gcc-3.4.1.tar.bz2 # Tar-jxvf arm-linux-gcc-3.4.1.tar.bz2 The decompression process takes some time. The decompressed file forms a usr/local/folder. Enter this folder and copy the arm folder to/usr/local /. # Cd usr/local/ # Cp-rv arm/usr/local/ Current cross-Compilation Program The set is under/usr/local/ARM/3.4.1/bin.
4. Modify the environment variables and add the path of the cross compiler to the path. (There are three methods. We strongly recommend that you use method 1.) Method 1: Modify the/etc/bash. bashrc file. # Vim/etc/bash. bashrc Add: Export Path = $ path:/usr/local/ARM/3.4.1/bin export path. Method 2: Modify the/etc/profile file: # Vim/etc/profile Add path settings and add the following at the end to save the/etc/profile file: Export Path = $ path:/usr/local/ARM/3.4.1/BIN Method 3: # export Path = $ path:/usr/local/ARM/3.4.1/bin Note: (this is valid only on the current terminal !)
5. Make the new environment variable take effect immediately without restarting the computer. Method 1: # Source/root/. bashrc Method 2: # Source/etc/profile
6. Check whether the path is added to the path: # Echo $ path /Usr/local/ARM/bin is displayed, indicating that the path of the cross compiler has been added to path. So far, the cross-compilation environment installation is complete. (This article address: Http://blog.sina.com.cn/s/blog_5a155e330100bqjc.html ) 7. 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: reading specs from/usr/local/ARM/3.4.1/lib/GCC/ARM-Linux/3.4.1/specs configured: /work/crosstool-0.27/build/ARM-Linux/gcc-3.4.1-glibc-2.3.2/GCC-3.4.1/configure -- target = arm-Linux -- Host = i686-host_pc-linux-gnu

-- Prefix =/usr/local/ARM/3.4.1 -- With-headers =/usr/local/ARM/3.4.1/ARM

-Linux/include -- With-local-Prefix =/usr/local/ARM/3.4.1/ARM-Linux -- disable

-NLS -- enable-threads = POSIX -- enable-symvers = GNU -- enable-_ cxa_atexit -- enable-packages ages = C, c ++ -- enable-shared -- enable-c99 -- enable-Long-long thread model: posix gcc version 3.4.1
8. 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 the source program has an error, a prompt will be displayed. If no prompt is displayed, you can 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. This is the information displayed.

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.