CentOS GCC Upgrade tutorial
This article is reproduced from: http://wgkgood.blog.51cto.com/. thank you for your appreciation!
Recently due to reasons of demand, need to upgrade the current gcc-4.4.4 to gcc-4.6.1, considering there are multiple reasons, made a script Automatic Installation combined with batch tool distribution.
I. installation environment
System Version: centos6.0X64
GCC version: gcc-4.4.4
New GCC: gcc-4.6.1
Ii. Formal Installation
1. download and install the source code:
[Plain] view plaincopyprint?
- Download the following package:
- Gcc-4.6.1.tar.bz2gmp-4.3.2.tar.bz2mpc-0.8.1.tar.gzmpfr-2.4.2.tar.bz2
- As follows:
- Wgetftp: // token}
- Wgethttp: // ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2
- You can!
2. Unzip and install the tool in the following sequence: GMP, MPFR, MPC, and GCC.
1. Install GMP:
[Plain] view plaincopyprint?
- Tarjxfgmp-4.3.2.tar.bz2 & cdgmp-4.3.2/;./configure-prefix =/usr/local/gmp/& make & makeinstall
2. Install MPFR:
[Plain] view plaincopyprint?
- Tarjxfmpfr-2.4.2.tar.bz2; cdmpfr-2.4.2/;./configure-prefix =/usr/local/mpfr-with-gmp =/usr/local/gmp & make & makeinstall
3. Install MCM:
[Plain] view plaincopyprint?
- Tarxzfmpc-0.8.1.tar.gz; cdmpc-0.8.1 ;. /configure-prefix =/usr/local/MCM-with-mpfr =/usr/local/mpfr-with-gmp =/usr/local/gmp & make & makeinstall
Run the following command:
[Plain] view plaincopyprint?
- ExportLD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mcm/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/</span>
// This step is critical. If you do not set the variable, an error is returned.
4. Install GCC:
[Plain] view plaincopyprint?
- Tarjxfgcc-4.6.1.tar.bz2; cdgcc-4.6.1 ;. /configure-prefix =/usr/local/gcc-enable-threads = posix-disable-checking-disable-multilib-enable-versions ages = c, c ++-with-gmp =/usr/local/gmp-with-mpfr =/usr/local/mpfr/-with-mpc =/usr/local/mcm /&& make & makeinstall
[Plain] view plaincopyprint?
- Installation is complete! Then, make a link to use GCC.
- Mkdir-p/data/backup/'date + % Y % m % d'
- Mv/usr/bin/{gcc, g ++}/data/backup/'date + % Y % m % d'
- Create a soft link:
- Ln-s/usr/local/gcc/bin/gcc/usr/bin/gcc
- Ln-s/usr/local/gcc/bin/g ++/usr/bin/g ++
Iii. Test GCC
Directly enter gcc-v to view the gcc version 4.6.1 and related compilation parameters! Attach a simple installation script:
[Plain] view plaincopyprint?
- #! /Bin/sh
- # Automakeinstallgcc
- #2012-07-03
- Tarjxfgmp-4.3.2.tar.bz2 & cdgmp-4.3.2/;./configure-prefix =/usr/local/gmp/& make & makeinstall
- Sleep1
- Cd ../;tarjxfmpfr-2.4.2.tar.bz2; cdmpfr-2.4.2/;./configure-prefix =/usr/local/mpfr-with-gmp =/usr/local/gmp & make & makeinstall
- Cd .. /;tarxzfmpc-0.8.1.tar.gz; cdmpc-0.8.1 ;. /configure-prefix =/usr/local/MCM-with-mpfr =/usr/local/mpfr-with-gmp =/usr/local/gmp & make & makeinstall
- Cd .. /;tarjxfgcc-4.6.1.tar.bz2; cdgcc-4.6.1 ;. /configure-prefix =/usr/local/gcc-enable-threads = posix-disable-checking-disable-multilib-enable-versions ages = c, c ++-with-gmp =/usr/local/gmp-with-mpfr =/usr/local/mpfr/-with-mpc =/usr/local/mcm/
- If
- [$? -Eq0]; then
- Echo "Thisgccconfigureissuccess"
- Else
- Echo "Thisgccconfigureisfailed"
- Fi
- ExportLD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mcm/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/
- Make & makeinstall
- [$? -Eq0] & echoThisismakeinstallsuccess
/// Certificate ////--------------------------------------------------------------------------------------------------------------------------------------------------------------
Configure: error: cannot compute suffix of object files: cannot compile
Indeed, adding the MPFR and GPM lib directories to LD_LIBRARY_PATH solves theproblem. for some reason I thought configure wocould handle this for me since Igave it -- with-gmp and -- with-mpfr settings. wocould have been nice if configuretested for this and given a helpful error. in any event I'll close this out into invalid bug report.
Gmp and mpfr need to be installed and in. bash_profile (usually in the/root directory) Configure LD_LIBRARY_PATH and configure the lib corresponding to GMP and MPFR, for example: LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mpfr/2.4.0/lib: /usr/local/gmp/4.2.2/lib
Export LD_LIBRARY_PATH must be restarted to take effect or use source/root/. bash_profile
Error while loading shared libraries: libXXX. so. X: cannot open shared object file: No such file
1. Find the path libXXX. so. X, such as/usr/local/xxx/lib.
2. cd/etc
3. gedit ld. so. conf
4. Add/usr/local/xxx/lib
5. ldconfig