Production Environment of the ARM platform Cross Compiler: production of the middleware ARM platform Cross Compiler
Host environment:
- Ubuntu 12.04.1 64bit
- Gcc version 4.6.3
ubuntu 12.04.1 64bit gcc version 4.6.3
1. download the latest source code package
- Binutils-2.22.tar.gz
- Gcc-4.7.2.tar.bz2
- Gmp-5.0.5.tar.xz
- Mpfr-3.1.1.tar.xz
- Mpc-1.0.1.tar.gz
- Glibc-2.16.0.tar.xz
- Glibc-linuxthreads-2.5.tar.bz2
- Glibc-ports-2.16.0.tar.xz
- Linux-3.5.4.tar.bz2
binutils-2.22.tar.gz gcc-4.7.2.tar.bz2 gmp-5.0.5.tar.xz mpfr-3.1.1.tar.xz mpc-1.0.1.tar.gz glibc-2.16.0.tar.xz glibc-linuxthreads-2.5.tar.bz2 glibc-ports-2.16.0.tar.xz linux-3.5.4.tar.bz2
Put the above source code package ~ /Src directory
1. Configure the compiling environment
- Cd ~ /Src
- Vim armenv
- # Write the following content to the armenv file and save and exit
- TARGET = arm-linux-gnueabi
- PREFIX =/opt/cross/gcc-4.7.2/$ TARGET
- PATH = $ PREFIX/bin: $ PATH
- Export TARGET PREFIX PATH
- # Configure the compiling environment
- . Armenv
Cd ~ /Srcvim armenv # Write the following content into the armenv file and save it. Exit TARGET = arm-linux-gnueabiPREFIX =/opt/cross/gcc-4.7.2/$ TARGETPATH = $ PREFIX/bin: $ PATHexport target prefix path # configure the compiling environment. armenv
2. Compile binutils
- Tar-xzf binutils-2.22.tar.gz
- Mkdir binutils-build
- Cd binutils-build
- ../Binutils-2.22/configure -- target = $ TARGET -- prefix = $ PREFIX
- Make-j2
- Sudo make install
- Cd ..
tar -xzf binutils-2.22.tar.gzmkdir binutils-buildcd binutils-build../binutils-2.22/configure --target=$TARGET --prefix=$PREFIXmake -j2sudo make installcd ..
3. The first gcc Compilation
- Tar-xjf gcc-4.7.2.tar.bz2
- Mkdir gcc-bootstrap-build
- Tar-xf gmp-5.0.5.tar.xz
- Tar-xf mpfr-3.1.1.tar.xz
- Tar-xf mpc-1.0.1.tar.gz
- Cd gcc-4.7.2
- Mv-v gmp-5.0.5 gmp
- Music-v mpfr-3.1.1 mpfr
- Mv-v mpc-1.0.1
- Cd ../gcc-bootstrap-build
- ../Gcc-4.7.2/configure \
- -- Target = $ TARGET -- host = x86_64-linux-gnu -- build = x86_64-linux-gnu \
- -- Enable-targets = all -- prefix = $ PREFIX \
- -- Enable-versions ages = c -- with-newlib -- without-headers -- disable-nls \
- -- Disable-threads -- disable-shared -- disable-libmudflap -- disable-libssp \
- -- Disable-libgomp -- disable-decimal-float -- enable-checking = release \
- -- Disable-bootstrap -- disable-libquadmath \
- -- With-mpfr-include = $ (pwd)/../gcc-4.7.2/mpfr/src \
- -- With-mpfr-lib = $ (pwd)/mpfr/src/. libs
- Make-j2 all-gcc
- Make-j2 all-target-libgcc
- Sudo make install-gcc
- Sudo make install-target-gcc
- Sudo cp-v libiberty/libiberty. a $ PREFIX/lib
- # Add a soft link from libgcc_eh.a and libgcc_s.a to libgcc. a below to prevent errors during library C Compilation
- Sudo ln-vs libgcc. a 'arm-linux-gnueabi-gcc-print-libgcc-file-name | sed's/libgcc/& _ eh /''
- Sudo ln-vs libgcc. a 'arm-linux-gnueabi-gcc-print-libgcc-file-name | sed's/libgcc/& _ s /''
- Cd ..
Tar-xjf gcc-4.7.2.tar.bz2mkdir gcc-bootstrap-buildtar-xf gmp-5.0.5.tar.xztar-xf mpfr-3.1.1.tar.xztar-xf mpc-1.0.1.tar.gzcd gcc-4.7.2mv-v gmp-5.0.5 gmpmv-v mpfr-3.1.1 mpfrmv-v mpc-1.0.1 mpccd .. /gcc-bootstrap-build .. /gcc-4.7.2/configure \ -- target = $ TARGET -- host = x86_64-linux-gnu -- build = x86_64-linux-gnu \ -- enable-targets = all -- prefix = $ PREFIX \ -- enable-versions ages = c --- newlib -- without-headers -- disable-nls \ -- disable-threads -- disable-shared -- disable-libmudflap -- disable-libssp \ -- disable-libgomp -- disable-decimal-float -- enable- checking = release \ -- disable-bootstrap -- disable-libquadmath \ -- with-mpfr-include = $ (pwd) /.. /gcc-4.7.2/mpfr/src \ -- with-mpfr-lib = $ (pwd)/mpfr/src /. libsmake-j2 all-gcc make-j2 all-target-libgccsudo make install-gccsudo make install-target-gccsudo cp-v libiberty/libiberty. a $ PREFIX/lib # Add libgcc_eh.a, libgcc_s.a to libgcc below. a soft link to prevent errors in compiling C library sudo ln-vs libgcc. a 'arm-linux-gnueabi-gcc-print-libgcc-file-name | sed's/libgcc/& _ eh/''sudo ln-vs libgcc. a 'arm-linux-gnueabi-gcc-print-libgcc-file-name | sed's/libgcc/& _ s/''cd ..
4. Install the kernel header file
- Tar-xjf linux-3.5.4.tar.bz2
- Cd linux-3.5.4
- Make ARCH = arm headers_check
- Make ARCH = arm INSTALL_HDR_PATH = dest headers_install
- Sudo cp-rv dest/include/* $ PREFIX/$ TARGET/include
- Note: The kernel header file is installed at $ PREFIX/$ TARGET/include, instead of $ PREFIX.
- Cd ..
Tar-xjf linux-3.5.4.tar.bz2cd linux-3.5.4make ARCH = arm headers_checkmake ARCH = arm INSTALL_HDR_PATH = dest headers_installsudo cp-rv dest/include/* $ PREFIX/$ TARGET/include note: the kernel header file is installed at $ PREFIX/$ TARGET/include, instead of $ PREFIXcd ..
5. Compile the C library
- Tar-xf glibc-2.16.0.tar.xz
- Tar-xjf glibc-linuxthreads-2.5.tar.bz2-C glibc-2.16.0
- Tar-xf glibc-ports-2.16.0.tar.xz
- Mv glibc-ports-2.16.0 glibc-2.16.0/ports
- Mkdir glibc-build
- Cd glibc-build
- CC = $ TARGET-gcc \
- AR = $ TARGET-ar \
- RANLIB = $ TARGET-ranlib \
- ../Glibc-2.16.0/configure \
- -- Host = $ TARGET \
- -- Prefix = $ PREFIX/$ TARGET \
- -- With-tls -- disable-profile \
- -- Enable-add-ons -- with-headers = $ PREFIX/$ TARGET/include \
- Libc_cv_forced_unwind = yes libc_cv_c_cleanup = yes libc_cv_arm_tls = yes
- Note: the installation location of the C library is $ PREFIX/$ TARGET. It is used when compiling the complete gcc.
- Sudo make-j2
- Sudo-s
- .../Armenv
- Make install
- Exit
- Cd ..
Tar-xf glibc-2.16.0.tar.xztar-xjf glibc-linuxthreads-2.5.tar.bz2-C glibc-2.16.0tar-xf glibc-ports-2.16.0.tar.xzmv glibc-ports-2.16.0 glibc-2.16.0/portsmkdir glibc-buildcd glibc-buildCC = $ TARGET-gcc \ AR = $ TARGET-ar \ RANLIB = $ TARGET -ranlib \.. /glibc-2.16.0/configure \ -- host = $ TARGET \ -- prefix = $ PREFIX/$ TARGET \ -- with-tls -- disable-profile \ -- enable-add-ons -- with-headers = $ PREFIX/$ TARGET/include \ libc_cv_forced_unwind = yes libc_cv_c_cleanup = yes libc_cv_arm_tls = yes Note: the installation location of the C library is $ PREFIX/$ TARGET. when compiling the complete gcc, the link uses sudo make-j2sudo-s... /armenvmake installexitcd ..
6. Compile the complete gcc
- Tar-xf gmp-5.0.5.tar.xz
- Cd gmp-5.0.5
- ./Configure -- prefix =/usr
- Make-j2
- Sudo make install
- Cd ..
- Tar-xf mpfr-3.1.1.tar.xz
- Cd mpfr-3.1.1
- ./Configure -- prefix =/usr
- Make-j2
- Sudo make install
- Cd ..
- Tar-xf mpc-1.0.1.tar.gz
- Cd mpc-1.0.1
- ./Configure -- prefix =/usr
- Make-j2
- Sudo make install
- Cd ..
- # If gmp, mpfr, and MCM are installed in the system and the version meets the requirements, you do not need to compile and install them.
- # During the build process, install the three components in other locations, add the link search path, and try them several times.
- # If you have time to try again, it is estimated that the configuration is incorrect.
- ../Gcc-4.7.2/configure -- target = $ TARGET \
- -- Host = x86_64-linux-gnu -- build = x86_64-linux-gnu \
- -- Prefix = $ PREFIX \
- -- Enable-languages ages = c, c ++ -- enable-shared
- Make-j2
- Sudo make install
- Cd ..
Tar-xf gmp-5.0.5.tar.xzcd gmp-5.0.5. /configure -- prefix =/usrmake-j2sudo make installcd ..tar-xf mpfr-3.1.1.tar.xzcd mpfr-3.1.1. /configure -- prefix =/usrmake-j2sudo make installcd ..tar-xf mpc-1.0.1.tar.gzcd mpc-1.0.1. /configure -- prefix =/usrmake-j2sudo make installcd .. # If gmp, mpfr, and MCM are installed in the system and the version meets the requirements, you do not need to compile and install them. # During the build process, install the three components in other locations, add the link search path, and try them several times. # If you have time to try again, it is estimated that the configuration is incorrect... /Gcc-4.7.2/configure -- target = $ TARGET \ -- host = x86_64-linux-gnu -- build = x86_64-linux-gnu \ -- prefix = $ PREFIX \ -- enable-versions ages = c, c ++ -- enable-sharedmake-j2sudo make installcd ..
7. Test
(1) dynamic compilation
- Arm-linux-gnueabi-gcc-o hello. c
- Arm-linux-gnu-eabi-strip hello
- File hello
- Hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
arm-linux-gnueabi-gcc -o hello hello.carm-linux-gnu-eabi-strip hellofile hellohello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
(2) Static Compilation
- Arm-linux-gnueabi-gcc-o hello. c-static
- Arm-linux-gnu-eabi-strip hello
- Hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, stripped
arm-linux-gnueabi-gcc -o hello hello.c -staticarm-linux-gnu-eabi-strip hellohello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, stripped
It has not been put into the Development Board for testing. It will be set up in the Development Board environment and updated after testing.