Production of the ARM platform Cross Compiler

Source: Internet
Author: User
Tags gmp
Production Environment of the ARM platform Cross Compiler: production of the middleware ARM platform Cross Compiler

Host environment:

  1. Ubuntu 12.04.1 64bit
  2. Gcc version 4.6.3
   ubuntu 12.04.1 64bit   gcc version 4.6.3

 


1. download the latest source code package
  1. Binutils-2.22.tar.gz
  2. Gcc-4.7.2.tar.bz2
  3. Gmp-5.0.5.tar.xz
  4. Mpfr-3.1.1.tar.xz
  5. Mpc-1.0.1.tar.gz
  6. Glibc-2.16.0.tar.xz
  7. Glibc-linuxthreads-2.5.tar.bz2
  8. Glibc-ports-2.16.0.tar.xz
  9. 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
  1. Cd ~ /Src
  2. Vim armenv
  3. # Write the following content to the armenv file and save and exit
  4. TARGET = arm-linux-gnueabi
  5. PREFIX =/opt/cross/gcc-4.7.2/$ TARGET
  6. PATH = $ PREFIX/bin: $ PATH
  7. Export TARGET PREFIX PATH
  8. # Configure the compiling environment
  9. . 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
  1. Tar-xzf binutils-2.22.tar.gz
  2. Mkdir binutils-build
  3. Cd binutils-build
  4. ../Binutils-2.22/configure -- target = $ TARGET -- prefix = $ PREFIX
  5. Make-j2
  6. Sudo make install
  7. 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

  1. Tar-xjf gcc-4.7.2.tar.bz2
  2. Mkdir gcc-bootstrap-build
  3. Tar-xf gmp-5.0.5.tar.xz
  4. Tar-xf mpfr-3.1.1.tar.xz
  5. Tar-xf mpc-1.0.1.tar.gz
  6. Cd gcc-4.7.2
  7. Mv-v gmp-5.0.5 gmp
  8. Music-v mpfr-3.1.1 mpfr
  9. Mv-v mpc-1.0.1
  10. Cd ../gcc-bootstrap-build
  11. ../Gcc-4.7.2/configure \
  12. -- Target = $ TARGET -- host = x86_64-linux-gnu -- build = x86_64-linux-gnu \
  13. -- Enable-targets = all -- prefix = $ PREFIX \
  14. -- Enable-versions ages = c -- with-newlib -- without-headers -- disable-nls \
  15. -- Disable-threads -- disable-shared -- disable-libmudflap -- disable-libssp \
  16. -- Disable-libgomp -- disable-decimal-float -- enable-checking = release \
  17. -- Disable-bootstrap -- disable-libquadmath \
  18. -- With-mpfr-include = $ (pwd)/../gcc-4.7.2/mpfr/src \
  19. -- With-mpfr-lib = $ (pwd)/mpfr/src/. libs
  20. Make-j2 all-gcc
  21. Make-j2 all-target-libgcc
  22. Sudo make install-gcc
  23. Sudo make install-target-gcc
  24. Sudo cp-v libiberty/libiberty. a $ PREFIX/lib
  25. # Add a soft link from libgcc_eh.a and libgcc_s.a to libgcc. a below to prevent errors during library C Compilation
  26. Sudo ln-vs libgcc. a 'arm-linux-gnueabi-gcc-print-libgcc-file-name | sed's/libgcc/& _ eh /''
  27. Sudo ln-vs libgcc. a 'arm-linux-gnueabi-gcc-print-libgcc-file-name | sed's/libgcc/& _ s /''
  28. 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
  1. Tar-xjf linux-3.5.4.tar.bz2
  2. Cd linux-3.5.4
  3. Make ARCH = arm headers_check
  4. Make ARCH = arm INSTALL_HDR_PATH = dest headers_install
  5. Sudo cp-rv dest/include/* $ PREFIX/$ TARGET/include
  6. Note: The kernel header file is installed at $ PREFIX/$ TARGET/include, instead of $ PREFIX.
  7. 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
  1. Tar-xf glibc-2.16.0.tar.xz
  2. Tar-xjf glibc-linuxthreads-2.5.tar.bz2-C glibc-2.16.0
  3. Tar-xf glibc-ports-2.16.0.tar.xz
  4. Mv glibc-ports-2.16.0 glibc-2.16.0/ports
  5. Mkdir glibc-build
  6. Cd glibc-build
  7. CC = $ TARGET-gcc \
  8. AR = $ TARGET-ar \
  9. RANLIB = $ TARGET-ranlib \
  10. ../Glibc-2.16.0/configure \
  11. -- Host = $ TARGET \
  12. -- Prefix = $ PREFIX/$ TARGET \
  13. -- With-tls -- disable-profile \
  14. -- Enable-add-ons -- with-headers = $ PREFIX/$ TARGET/include \
  15. Libc_cv_forced_unwind = yes libc_cv_c_cleanup = yes libc_cv_arm_tls = yes
  16. Note: the installation location of the C library is $ PREFIX/$ TARGET. It is used when compiling the complete gcc.
  17. Sudo make-j2
  18. Sudo-s
  19. .../Armenv
  20. Make install
  21. Exit
  22. 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
  1. Tar-xf gmp-5.0.5.tar.xz
  2. Cd gmp-5.0.5
  3. ./Configure -- prefix =/usr
  4. Make-j2
  5. Sudo make install
  6. Cd ..
  7. Tar-xf mpfr-3.1.1.tar.xz
  8. Cd mpfr-3.1.1
  9. ./Configure -- prefix =/usr
  10. Make-j2
  11. Sudo make install
  12. Cd ..
  13. Tar-xf mpc-1.0.1.tar.gz
  14. Cd mpc-1.0.1
  15. ./Configure -- prefix =/usr
  16. Make-j2
  17. Sudo make install
  18. Cd ..
  19. # 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.
  20. # During the build process, install the three components in other locations, add the link search path, and try them several times.
  21. # If you have time to try again, it is estimated that the configuration is incorrect.
  22. ../Gcc-4.7.2/configure -- target = $ TARGET \
  23. -- Host = x86_64-linux-gnu -- build = x86_64-linux-gnu \
  24. -- Prefix = $ PREFIX \
  25. -- Enable-languages ages = c, c ++ -- enable-shared
  26. Make-j2
  27. Sudo make install
  28. 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
  1. Arm-linux-gnueabi-gcc-o hello. c
  2. Arm-linux-gnu-eabi-strip hello
  3. File hello
  4. 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
  1. Arm-linux-gnueabi-gcc-o hello. c-static
  2. Arm-linux-gnu-eabi-strip hello
  3. 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.
Related Article

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.