CentOS GCC Upgrade tutorial

Source: Internet
Author: User

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?
  1. Download the following package:
  2. Gcc-4.6.1.tar.bz2gmp-4.3.2.tar.bz2mpc-0.8.1.tar.gzmpfr-2.4.2.tar.bz2
  3. As follows:
  4. Wgetftp: // token}
  5. Wgethttp: // ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2
  6. You can!

 

2. Unzip and install the tool in the following sequence: GMP, MPFR, MPC, and GCC.

1. Install GMP:

[Plain] view plaincopyprint?
  1. Tarjxfgmp-4.3.2.tar.bz2 & cdgmp-4.3.2/;./configure-prefix =/usr/local/gmp/& make & makeinstall

2. Install MPFR:

[Plain] view plaincopyprint?
  1. 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?
  1. 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?
  1. 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?
  1. 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?
  1. Installation is complete! Then, make a link to use GCC.
  2. Mkdir-p/data/backup/'date + % Y % m % d'
  3. Mv/usr/bin/{gcc, g ++}/data/backup/'date + % Y % m % d'
  4. Create a soft link:
  5. Ln-s/usr/local/gcc/bin/gcc/usr/bin/gcc
  6. 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?
  1. #! /Bin/sh
  2. # Automakeinstallgcc
  3. #2012-07-03
  4. Tarjxfgmp-4.3.2.tar.bz2 & cdgmp-4.3.2/;./configure-prefix =/usr/local/gmp/& make & makeinstall
  5. Sleep1
  6. Cd ../;tarjxfmpfr-2.4.2.tar.bz2; cdmpfr-2.4.2/;./configure-prefix =/usr/local/mpfr-with-gmp =/usr/local/gmp & make & makeinstall
  7. 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
  8. 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/
  9. If
  10. [$? -Eq0]; then
  11. Echo "Thisgccconfigureissuccess"
  12. Else
  13. Echo "Thisgccconfigureisfailed"
  14. Fi
  15. ExportLD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mcm/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/
  16. Make & makeinstall
  17. [$? -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

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.