Compiling and installing GCC

Source: Internet
Author: User
Tags bz2 gcov gmp

1. Download the GCC source package: gcc-4.6.3.tar.bz2

2. Download gcc Dependency pack: gmp-5.0.4.tar.bz2, mpfr-3.1.0.tar.bz2, mpc-0.9.tar.gz

3. Decompression gcc-4.6.3.tar.bz2 instruction = "[Flydream@flydream opt]$ TAR-XVF gcc-4.6.3.tar.bz2

4. Enter [Flydream@flydream opt]$ CD gcc-4.6.3

5. Put the downloaded gmp-5.0.4.tar.bz2, mpfr-3.1.0.tar.bz2, mpc-0.9.tar.gz package into the gcc-4.6.3 directory

6. In the gcc-4.6.3 directory to extract the above three packets respectively

Install gmp-5.0.4.tar.bz2 First

Access to GMP directory: CD gmp-5.0.4

To establish the installation path: mkdir Gmp_install

CD Gmp_install

.. /configure--prefix=/opt/gcc-4.6.3/gmp-5.0.4/gmp_install

Make

Make install

Install mpfr-3.1.0.tar.bz2

Enter MPFR Directory

[Flydream@flydream gcc-4.6.3]$ CD mpfr-3.1.0

To establish the installation path: mkdir Mpfr_install

CD Mpfr_install

.. /configure--prefix=/opt/gcc-4.6.3/mpfr-3.1.0/mpfr_install--with-gmp=/opt/gcc-4.6.3/gmp-5.0.4/gmp_install

Make

Make install


Then install mpc-0.9.tar.gz

Into the MPC

To establish the installation path: mkdir Mpc_install

CD Mpc_install

.. /configure--prefix=/opt/gcc-4.6.3/mpc-0.9/mpc_install--with-gmp=/opt/gcc-4.6.3/gmp-5.0.4/gmp_install-- With-mpfr=/opt/gcc-4.6.3/mpfr-3.1.0/mpfr_install

Make

Make install


A "configure:error:cannot compute suffix of object Files:cannot compile" error may occur during the compilation of GCC, and the solution is:

Export Ld_library_path= $LD _library_path:/opt/gcc-4.6.3/mpc-0.9/mpc_install/lib:/opt/gcc-4.6.3/gmp-5.0.4/gmp_ Install/lib:/opt/gcc-4.6.3/mpfr-3.1.0/mpfr_install/lib

Last Install GCC

Set up the installation path outside of the GCC source directory

mkdir Gcc_install

.. /configure--prefix=/opt/gcc_install--with-gmp=/opt/gcc-4.6.3/gmp-5.0.4/gmp_install--with-mpfr=/opt/gcc-4.6.3/ Mpfr-3.1.0/mpfr_install----With-mpc=/opt/gcc-4.6.3/mpc-0.9/mpc_install--enable-checking=release-- program-suffix=4.6.3--enable-languages=c,c++

Make

Make install

Note the –program-suffix parameter, which represents the suffix of the generated executable file. The –enable-languages parameter represents the language to support. Final make; Make install. Make is also a small tip: because gcc files a lot, compile very slowly, you can use make-j n parameters, open multithreaded editing. Where the n value can be set to machine CPU kernel number x2.

Once compiled, you can use/opt/gcc-4.6.3/bin/gcc-4.6.3 to compile the C program. For ease of use,/opt/gcc-4.6.3/bin/gcc-4.6.3/bin can be placed in the system path:

Export path= $PATH:/opt/gcc-4.6.3/bin/gcc-4.6.3/bin

Building arm-linux-gnueabi-gcc-4.6.3 Cross-compilation chain

First, preparatory work

1. Prepare documents

binutils-2.22.tar.bz2

gcc-4.6.3.tar.bz2

Glibc-2.14.1.tar.xz

Glibc-ports-2.14.1.tar.gz

glibc-linuxthreads-2.5.tar.bz2

gdb-7.4.1.tar.bz2

linux-2.6.38.8.tar.bz2

mpfr-3.1.1.tar.bz2

Mpc-1.0.1.tar.gz

gmp-5.1.0.tar.bz2

2, set up the following variables, easy to wait for the input

#vim ~/.BASHRC

Export Target=arm-linux-gnueabi
Export prefix=/usr/local/arm-linux-gcc/4.6.3
Export target_prefix= $PREFIX/$TARGET
Export path= $PATH: $PREFIX/bin

3, for host installation MPFR, MPC, GMP

#tar-XVF gmp-5.1.0.tar.bz2

#cd gmp-5.1.0

#mkdir Build

#cd Build

#.. /configure

#make All-j4

#make Install

#tar-XVF mpfr-3.1.1.tar.bz2

# CD mpfr-3.1.1
#mkdir Build

#cd Build

#.. /configure

#make All-j4

#make Install

#tar-XVF mpc-1.0.1.tar.gz

#cd mpc-1.0.1

#mkdir Build

#cd Build

#.. /configure

#make All-j4

#make Install

4. Copy Linux-kernel-headers

#tar-XVF linux-2.6.38.8.tar.bz2

#cd linux-2.6.38.8

#make Include/linux/version.h
CHK Include/linux/version.h
UPD Include/linux/version.h

#mkdir-P $TARGET _prefix/include

#cp-R/include/linux/$TARGET _prefix/include

#cp-R/include/asm-generic/$TARGET _prefix/include

#cp-R/arch/arm/include/asm/$TARGET _prefix/include

Second, compile Binutils

#tar-XVF binutils-2.22.tar.bz2

#cd binutils-2.22

#mkdir Build

#cd Build

#.. /configure--prefix= $PREFIX--target= $TARGET

#make All-j4

#make Install

Iii. Preliminary compilation of GCC (without glibc support)

#tar-XVF gcc-4.6.3.tar.bz2

Re-extract mpfr-3.1.1.tar.bz2, mpc-1.0.1.tar.gz, gmp-5.1.0.tar.bz2, and change the name to gcc-4.6.3

#rm-rf mpfr-3.1.1 mpc-1.0.1 gmp-5.1.0

#tar-XVF gmp-5.1.0.tar.bz2

#mv gmp-5.1.0 GMP

#mv./gmp./gcc-4.6.3

#tar-XVF mpfr-3.1.1.tar.bz2

#mv mpfr-3.1.1 MPFR

#mv./mpfr./gcc-4.6.3

#tar-XVF mpc-1.0.1.tar.gz

#mv mpc-1.0.1 MPC

#mv./mpc./gcc-4.6.3

#cd gcc-4.6.3

#mkdir Build

#cd Build

#.. /configure--prefix= $PREFIX--target= $TARGET--without-headers--enable-languages=c--disable-threads--with-newlib- -disable-shared--disable-libmudflap--DISABLE-LIBSSP--disable-decimal-float
#make All-gcc-j4

#make INSTALL-GCC

#make All-target-libgcc-j4

#make INSTALL-TARGET-LIBGCC

Iv. compiling glibc

#tar-XVF Glibc-2.14.1.tar.xz

#tar-XVF glibc-ports-2.14.1.tar.gz

#mv glibc-ports-2.14.1 Ports
#mv./ports/./glibc-2.14.1

#tar-XVF glibc-linuxthreads-2.5.tar.bz2--directory=./glibc-2.14.1

# CD glibc-2.14.1

# mkdir Build

# CD Build

# cc= $TARGET-GCC

# ln-s/usr/local/arm-linux-gcc/4.6.3/lib/gcc/arm-linux-gnueabi/4.6.3/libgcc.a/usr/local/arm-linux-gcc/4.6.3/lib /gcc/arm-linux-gnueabi/4.6.3/libgcc_eh.a

Creating a Config.cache configuration file

# Vim Config.cache

Libc_cv_forced_unwind=yes

Libc_cv_c_cleanup=yes

Libc_cv_arm_tls=yes

# .. /configure--host= $TARGET--target= $TARGET--prefix= $TARGET _prefix--enable-add-ons--disable-profile--cache-file= Config.cache--with-binutils= $PREFIX/bin--with-headers= $TARGET _prefix/include

#make All-j4

#make Install

V. Re-compiling GCC

# CD gcc-4.6.3/build/

# RM-RF *

# .. /configure--prefix= $PREFIX--target= $TARGET--enable-shared--enable-languages=c,c++

# Make All-j4

# make Install

Six, compile GDB

# TAR-XVF GDB-7.4.1.TAR.BZ2
# .. /configure--prefix= $PREFIX--target= $TARGET

# Make All-j4

# make Install

Seven, create a link

# CD $PREFIX/bin

# ln-s Arm-linux-gnueabi-addr2line Arm-linux-addr2line
# ln-s Arm-linux-gnueabi-ar Arm-linux-ar
# ln-s Arm-linux-gnueabi-as Arm-linux-as
# ln-s Arm-linux-gnueabi-c++ arm-linux-c++
# ln-s Arm-linux-gnueabi-c++filt arm-linux-c++filt
# ln-s Arm-linux-gnueabi-cpp Arm-linux-cpp
# ln-s Arm-linux-gnueabi-elfedit Arm-linux-elfedit
# ln-s arm-linux-gnueabi-g++ arm-linux-g++
# ln-s ARM-LINUX-GNUEABI-GCC ARM-LINUX-GCC
# ln-s arm-linux-gnueabi-gcc-4.6.3 arm-linux-gcc-4.6.3
# ln-s Arm-linux-gnueabi-gcov Arm-linux-gcov
# ln-s Arm-linux-gnueabi-gdb arm-linux-gdb
# ln-s Arm-linux-gnueabi-gdbtui Arm-linux-gdbtui
# ln-s Arm-linux-gnueabi-gprof arm-linux-gprof
# ln-s Arm-linux-gnueabi-ld Arm-linux-ld
# ln-s ARM-LINUX-GNUEABI-LD.BFD ARM-LINUX-LD.BFD
# ln-s ARM-LINUX-GNUEABI-NM arm-linux-nm
# ln-s Arm-linux-gnueabi-objcopy arm-linux-objcopy
# ln-s Arm-linux-gnueabi-objdump Arm-linux-objdump
# ln-s Arm-linux-gnueabi-ranlib Arm-linux-ranlib
# ln-s Arm-linux-gnueabi-readelf arm-linux-readelf
# ln-s Arm-linux-gnueabi-run Arm-linux-run
# ln-s Arm-linux-gnueabi-size arm-linux-size
# ln-s Arm-linux-gnueabi-strings arm-linux-strings
# ln-s Arm-linux-gnueabi-strip Arm-linux-strip

Complete


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.