Ubuntu 12.04 64bit gcc cross compiler made original

Source: Internet
Author: User
Tags posix


To do embedded development without cross-platform operations, so there is also the use of cross-compiler, we can create our own custom cross-compiler, which can be customized some things can be used to support the special requirements such as floating-point operations. The following is an example of the ARMGCC cross compiler for the most commonly used arm platform for embedded development: As with other platform steps and methods, just make the appropriate changes when the platform is selected. Preparation: 1. Download the tool to create a cross-compilation environment: Crosstool (crosstool-0.43.tar.gz) using the command line to download

wget http://www.kegel.com/crosstool/crosstool-0.43.tar.gz

2. Download the source code needed for the compilation process:

binutils-2.15.tar.bz2

gcc-3.4.5.tar.bz2

glibc-2.3.6.tar.bz2

glibc-linuxthreads-2.3.6.tar.bz2

linux-2.6.8.tar.bz2

LINUX-LIBC-HEADERS-2.6.12.0.TAR.BZ2 Description: The specific version number can be a little different, and then talk about how to set up.      The above seven software recommendations are placed in the same directory, such as the ~/linux/downloads directory. 3. The compilation process needs to use the following software, the system itself is not installed, you can run the installation command well in advance, because the compilation will take at least half an hour, if the dependent software is not installed halfway through the error exits, only from the beginning, that is a waste of time.

sudo apt-get install Bison flex build-essential Patch Libncurses5-dev

Specific work steps:

1. Modify the System configuration

1.1 Set the GCC version to 4.1

Ubuntu 12.04 64bit The default installation of the GCC version is 4.6, this version of the syntax requirements are high, compile will be wrong, is not suitable for selection, so chose gcc-4.1, but do not need to uninstall gcc-4.6.

sudo apt-get install gcc-4.1 (currently new can not be installed directly, you need to download gcc-4.1 manual installation, please see Ubuntu 12.04 64bit installation compiled GCC 4.1.2 absolutely original)

sudo rm/usr/bin/gcc (remove gcc, it's just a soft link file to gcc-4.6)

sudo ln-s/usr/bin/gcc-4.1/usr/bin/gcc (build gcc to gcc-4.1 soft link)

1.2 Modifying the SH version

If you run ls-la/bin/sh to see that the link is dash, run the following command

sudo dpkg-reconfigure Dash

Select No to remove dash here error will occur at compile time if not changed

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

$CD Downloads $tar –zxvf crosstool-0.43.tar.gz

$CD crosstool-0.43 You can see a lot of. SH scripts and. Dat profiles in this directory, each supported processor has its corresponding script. If the choice of demo-arm-softfloat.sh is to set up the arm cross-compiler tool chain to support soft floating point.


3. Modify Demo-arm-softfloat.sh $vim demo-arm-softfloat.sh

Modify the following two sentences tarballs_dir= $HOME/downloads//Indicates the source of the download directory

Result_top=/opt/crosstools//Indicates the storage directory of the generated tool chain

As: tarballs_dir=/home/linux/downloads (source storage directory)

Result_top=/home/linux/crosstools (Generate tool chain catalog) 4. Modify Gcc-3.4.5-glibc-2.3.6.dat $ vim Gcc-3.4.5-glibc-2.3.6.dat Modify the content as: BINU tils_dir=binutils-2.15

gcc_dir=gcc-3.4.5

glibc_dir=glibc-2.3.6

linux_dir=linux-2.6.8

linux_sanitized_header_dir=linux-libc-headers-2.6.12.0

glibcthreads_filename=glibc-linuxthreads-2.3.6

5 $./demo-arm-softfloat.sh This process is longer (about half an hour)

6. Modifying environment variables
Modify/HOME/LINUX/.BASHRC Cd/home/linux directly

Vim. BASHRC add the following on the last side:

Path= $PATH:/home/linux/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin

Then source. bashrc

7. Execute the following command
$ arm-softfloat-linux-gnu-gcc-v

    display  
Reading Specs from/home/david/project/crosstool/ Gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/lib/gcc/arm-softfloat-linux-gnu/3.4.5/specs  
Configured With:/home/david/downloads/crosstool-0.43/build/arm-softfloat-linux-gnu/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/ Configure--target=arm-softfloat-linux-gnu--host=i686-host_pc-linux-gnu--prefix=/home/david/project/crosstool/ Gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu--with-float=soft--with-headers=/home/david/project/crosstool/ Gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu/include--with-local-prefix=/home/david/ Project/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu--disable-nls-- Enable-threads=posix--enable-symvers=gnu--enable-__cxa_atexit--enable-languages=c,c++--enable-shared-- Enable-c99--enable-long-long 
  hread model:posix gcc version 3.4.5 
 ok Cross-compilation environment created successfully!


8. Restore the System configuration we modified:

Restore GCC to 4.6

sudo rm/usr/bin/gcc

sudo ln-s/USR/BIN/GCC-4.6/USR/BIN/GCC

Re-install Dash

sudo dpkg-reconfigure Dash

Select Yes to reinstall Dash

Attention:

1.ubuntu12.04 the tool chain on the build execution. The following error occurs during the/demo-arm-softflaot.sh process:
"These critical programs is missing or too old" as LD
Here's how to fix it:


Modify the following file:
VI./build/arm-softfloat-linux-gnu/gcc-3.4.5-glibc-2.3.6/glibc-2.3.6/configure (4425 rows of{(exit 1); exit 1;}; Block out because the Binuilts version is too low to cause an abnormal exit)
Will
4419 test-n "$critic _missing" && {echo "$as _me: $LINENO: Error:
4420 * * * These critical programs is missing or too old: $critic _missing
4421 * * * Check the INSTALL file for required versions. ">&5
4422 echo "$as _me:error:
I

4423 * * * These critical programs is missing or too old: $critic _missing
4424 * * * Check the INSTALL file for required versions. ">&2;}
{(exit 1); exit 1;};}
Switch
4419 test-n "$critic _missing" && {echo "$as _me: $LINENO: Error:
4420 * * * These critical programs is missing or too old: $critic _missing
4421 * * * Check the INSTALL file for required versions. ">&5
4422 echo "$as _me:error:
4423 * * * These critical programs is missing or too old: $critic _missing
4424 * * * Check the INSTALL file for required versions. ">&2;}
#{(exit 1); exit 1;};
}
Before you execute the./demo-arm-softfloat.sh, in the eval ' cat arm-softfloat.dat gcc-3.4.5-glibc-2.3.6.dat ' sh all.sh--notest Add--nounpack at the end to not re-unzip the installation package to allow the installation process to continue without overwriting the Configure problem and previous compilation results
Execute again:
./demo-arm-softfloat.sh









































Ubuntu 12.04 64bit gcc cross compiler made original

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.