Ubuntu11.04 server compilation and installation gcc4.6.1

Source: Internet
Author: User
Tags gmp

Install required Libraries

Sudo apt-Get install build-essential

Sudo apt-Get install zlibc

Sudo apt-Get install zlib1g-dev

Sudo apt-Get install M4

Sudo apt-Get install gcc-multilib

Obtain source code

Go to the/usr/src directory
Wget http://gcc.igor.onlinedirect.bg/releases/gcc-4.6.1/gcc-4.6.1.tar.bz2
Tar jxvf gcc-4.6.1.tar.bz2

Compile the dependent library GMP

Wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
Tar jxvf gmp-4.3.2.tar.bz2
Mkdir gmp_build
CD gmp_build
../Gmp-4.3.2/configure-Prefix =/usr/gmp-4.3.2
Make
Make check
Make install

Mpfr

Wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
Tar jxvf mpfr-2.4.2.tar.bz2
Mkdir mpfr_build
CD mpfr_build
../Mpfr-2.4.2/configure-Prefix =/usr/mpfr-2.4.2-with-GMP =/usr/gmp-4.3.2
Make
Make check
Make install

MPC

Wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
Tar zxvf mpc-0.8.1.tar.gz
Mkdir mpc_build
CD mpc_build
../Mpc-0.8.1/configure-Prefix =/usr/mpc-0.8.1-with-GMP =/usr/gmp-4.3.2-with-mpfr =/usr/mpfr-2.4.2
Make
Make check
Make install

Compile gcc

Mkdir gcc_build
CD gcc_build
.. /Gcc-4.6.1/configure-Prefix =/usr/gcc-4.6.1-enable-threads = POSIX-Disable-checking-Disable-multilib-enable-versions ages = C, c ++-with-GMP =/usr/gmp-4.3.2-with-mpfr =/usr/mpfr-2.4.2-with-MPC =/usr/mpc-0.8.1
Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/mpc-0.8.1/lib:/usr/gmp-4.3.2/lib:/usr/mpfr-2.4.2/lib
Make
Apt-Get install dejagnu
Apt-Get install autogen
Make check
Make install

If compile error, can't find error. h In some files, use the following command:
Sudo ln-SV/usr/src/linux-headers-2.6.38-10/ARCH/x86/include/ASM/usr/include/ASM

Replace the old GCC version

The old version of GCC is in the/usr/bin directory.

CD/usr/bin
Mv gcc gcc_bk
MV g ++ _ BK
Mv cpp cpp_bk
Mv c ++ _ BK

Use the newest version

Ln-S/usr/gcc-4.6.1/bin/GCC/usr/bin/GCC
Ln-S/usr/gcc-4.6.1/bin/g + +/usr/bin/g + +
Ln-S/usr/gcc-4.6.1/bin/CPP/usr/bin/CPP
Ln-S/usr/gcc-4.6.1/bin/C ++/usr/bin/C ++

Add following into/etc/profile file

LD_LIBRARY_PATH =/usr/mpc-0.8.1/lib:/usr/gmp-4.3.2/lib:/usr/mpfr-2.4.2/lib:/usr/gcc-4.6.1/lib:/usr/lib
Export LD_LIBRARY_PATH

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.