Ubuntu10.04 build a cross compiler gcc

Source: Internet
Author: User
Environment: Ubuntu10.04 target board: s3c2410 installation of cross-compiling environment 1. install the Standard C development environment. Because Ubuntu is not installed by default, You need to first install: unzip, and then unzip sudotarjxvf/home/eng

Environment: Ubuntu 10.04 target board: s3c2410 cross-compilation environment

1. install the Standard C development environment. Because Ubuntu is not installed by default, you need to install sudo apt-get install gcc g ++ libgpc3 libg ++ make gdb first.

Unzip, then decompress sudo tar jxvf/home/engelbert/cross-3.2.tar.bz2 (/home/engelbert/ Save the path of cross-3.2.tar.bz2), and then transfer all the extracted files to/usr/local, sudo mv/home/engelbert/usr/local/arm/usr/local

3. Add the PATH of the cross compiler to PATH sudo vi/etc/bash. bashrc and add the following code to the end:

If

[-D/usr/local/arm];

Then PATH =/usr/local/arm/bin: "$ {PATH }"

Fi

4. Make the new environment variable take effect # source/etc/profile

5. check whether the PATH is added to the PATH. echo $ PATH: If/usr/local/arm/bin is displayed, the PATH of the cross compiler has been added to the PATH, cross-compilation environment installation is complete.

Let's test a simple example.

/* Hello. c */# include main () {printf ("hello ubuntu! \ N ");}

After the program is lost, confirm it is correct and save it.

Go to the arm-linux-gcc hello. c-o hello directory where the program file is located (-o can be understood as "the target is generated ")

Arm-linux-gcc is the first appearance. Some people may ask where to come from, open the installed cross-compilation tool directory/usr/local/arm-linux/bin/and you will find an arm-linux-gcc file in it, this is the gcc compiler for arm CPU. In the future, you can use other compilation tool chain to see what the compiler is. After compilation, you can download it to the target machine for testing. Of course, you can test the correctness on a PC first.

You can use gcc hello. c-o hello to generate a program on the PC, and run./hello to find that the terminal displays hello! .

A program compiled with arm-linux-gcc cannot run on a PC. After running the program, an error report is provided: the binary file cannot be executed. It indicates that the files compiled in the Cross-compilation environment are binary code files that can be executed by hardware.

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.