First download the corresponding source code:
Ftp://ftp.dti.ad.jp/pub/lang/gcc/releases/gcc-4.6.1/
#下载 gcc-4.6.1.tar.bz2
Ftp://ftp.dti.ad.jp/pub/lang/gcc/infrastructure/
#下载 gmp-4.3.2.tar.bz2 mpfr-2.4.2.tar.bz2 mpc-0.8.1.tar.gz
Step 0:
123 |
$sudo apt-get Install build-essential$sudo apt-get install zlibc$sudo apt-get Install Zlib1g-dev |
Step 1: Install gmp-4.3.2
1234 |
#cd to src_dir$./configure--prefix=/usr/local/gmp-4.3.2$make$sudo make install |
Step 2: Install mpfr-2.4.2
1234 |
#cd to Src_dir$./configure--prefix=/usr/local/mpfr-2.4.2--with-gmp=/usr/local/gmp-4.3.2$make$sudo make install |
Step 3: Install mpc-0.8.1
1234 |
#cd to Src_dir$./configure--prefix=/usr/local/mpc-0.8.1--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/ Mpfr-2.4.2$make$sudo make Install |
Step 4: Install gcc-4.6.0
12345 |
$export ld_library_path= $LD _library_path:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/ MPFR-2.4.2/LIB#CD to Src_dir$./configure--prefix=/usr/local/gcc-4.6.1--enable-threads=posix--disable-checking-- Disable-multilib--enable-languages=c,c++--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/mpfr-2.4.2-- With-mpc=/usr/local/mpc-0.8.1$make$sudo make Install |
Step 5: Multi-version support
In order for Ubuntu to support multiple GCC versions, the following settings are required:
1234 |
$ sudo update-alternatives--install/usr/bin/gcc gcc/usr/bin/gcc-4.5 40$ sudo update-alternatives--install/usr/bin/gc C GCC/USR/LOCAL/GCC-4.6.1/BIN/GCC 60# Select the version you need $sudo update-alternatives--config gcc |
Step 6: Add a new version of shared library
In order to compile the software, you can use the latest shared library
1 |
$sudo vim/etc/ld.so.conf.d/x86_64-linux-gnu.conf |
Add the following:
/usr/local/gcc-4.6.1/lib64/
Save after execution, update shared library
Ubuntu 11.04 Installing GCC 4.6.1