Ubuntu 12.04 64bit GCC cross compiler original, ubuntu12.04
Cross-platform operations are indispensable for embedded development, and cross-compiler is also indispensable. We can create our own cross-compiler by ourselves, which can be customized, it supports Special requirements such as floating point operations. The following uses the ARMGCC cross compiler suitable for the most common ARM platform for Embedded Development as an example: the steps and methods of other platforms are the same, and you only need to make changes when selecting the platform. Preparations: 1. Download the tool used to create the cross-compilation environment: crosstool(crosstool-0.43.tar.gz) and download it using the command line
Wget http://www.kegel.com/crosstool/crosstool-0.43.tar.gz
2. Download the source code required 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 somewhat different, later said how to set. We recommend that you store the above seven software in the same directory, for example ~ /Linux/downloads directory. 3. the compilation process requires the following software. The system itself is not installed. You can run the installation command in advance, because it takes at least half an hour to compile, if the dependent software is not installed, an error will be reported and exited. It is a waste of time.
Sudo apt-get install bison flex build-essential patch libncurses5-dev
Procedure:
1. Modify system configurations
1.1 set the GCC version to 4.1
Ubuntu 12.04 64bit gcc version installed by default is 4.6, this version for syntax requirements are higher, compilation will be wrong, it is not suitable for selection, so select the gcc-4.1, but do not need to uninstall the gcc-4.6.
Sudo apt-get install gcc-4.1 (currently new cannot be directly installed, You need to download your own gcc-4.1 manual installation, please refer to Ubuntu 12.04 64bit installation and compilation GCC 4.1.2 absolute original)
Sudo rm/usr/bin/gcc (delete GCC, it's just a soft link file to the gcc-4.6)
Sudo ln-s/usr/bin/gcc-4.1/usr/bin/gcc (create a soft link from GCC to gcc-4.1)
1.2 modify 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 delete dash. If no change is made, an error will occur during compilation.
2. decompress the software package and enter the directory to view important script files.
$ Cd downloads $ tar-zxvf crosstool-0.43.tar.gz
$ Cd crosstool-0.43 in this directory can see a lot of. sh scripts and. dat configuration files, each supporting processor has its corresponding script. If demo-arm-softfloat. sh is used, it is used to establish the arm cross-compilation tool chain with the goal of supporting soft floating points.
3. Modify demo-arm-softfloat.sh $ vim demo-arm-softfloat.sh
Modify the following two statements: TARBALLS_DIR = $ HOME/downloads // indicates the directory where the downloaded source code is stored.
RESULT_TOP =/opt/crosstools // indicates the directory where the generated toolchain is stored.
TARBALLS_DIR =/home/linux/downloads (source code directory)
RESULT_TOP =/home/linux/crosstools (generate the toolchain directory) 4. Modify the gcc-3.4.5-glibc-2.3.6.dat $ vim gcc-3.4.5-glibc-2.3.6.dat to: BINUTILS_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. Modify Environment Variables
Directly modify/home/linux/. bashrc cd/home/linux
Vim. bashrc adds the following content at the end:
PATH = $ PATH:/home/linux/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin
Then source. bashrc
7. Run 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: /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/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 ages = c, c ++ -- enable-shared -- enable-c99 -- enable-long
Hread model: posix gcc version 3.4.5
OK, the cross-compilation environment is successfully created!
8. Restore Our modified System Configuration:
Restore gcc to 4.6
Sudo rm/usr/bin/gcc
Sudo ln-s/usr/bin/gcc-4.6/usr/bin/gcc
Reinstall dash
Sudo dpkg-reconfigure dash
Select yes to reinstall dash
Note:
1. Execute the compilation of the toolchain on UBUNTU12.04./The following error occurs during the demo-arm-softflaot.sh process:
* ** "These critical programs are missing or too old" as ld
The solution is as follows:
Modify the following file:
Vi. /build/arm-softfloat-linux-gnu/gcc-3.4.5-glibc-2.3.6/glibc-2.3.6/configure (that is, block the {(exit 1); exit 1 ;}; of line 4425, because the binuilts version is too low, the system exits abnormally)
Set
4419 test-n "$ critic_missing" & {echo "$ as_me: $ LINENO: error:
4420 *** These critical programs are 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 are missing or too old: $ critic_missing
4424 *** Check the INSTALL file for required versions. "> & 2 ;}
{(Exit 1); exit 1 ;};}
Changed:
4419 test-n "$ critic_missing" & {echo "$ as_me: $ LINENO: error:
4420 *** These critical programs are missing or too old: $ critic_missing
4421 *** Check the INSTALL file for required versions. "> & 5
4422 echo "$ as_me: error:
4423 *** These critical programs are missing or too old: $ critic_missing
4424 *** Check the INSTALL file for required versions. "> & 2 ;}
# {(Exit 1); exit 1 ;};
}
Execute again. /demo-arm-softfloat.sh before, please arm-softfloat.dat in eval 'cat gcc-3.4.5-glibc-2.3.6.dat 'sh all. adding -- nounpack at the end of sh -- notest indicates that the installation package is not re-decompressed, so that the installation process continues without overwriting the configure problem and the previous compilation results.
Execute again:
/Demo-arm-softfloat.sh