linux - How do I install the latest gcc 4.7.0 on centos 6.2?

20
2014-04
  • q0987
    [root@localhost dyliu]# yum list gcc
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
     * base: centos.mirrors.tds.net
     * extras: centos.mirrors.tds.net
     * rpmforge: apt.sw.be
     * updates: mirror.ubiquityservers.com
    Installed Packages
    gcc.i686                    4.4.6-3.el6                    @anaconda-CentOS-201112130233.i386/6.2
    

    By default, if I run yum install gcc, the yum tool will install gcc 4.4.6 for me.

    Question> How to install the latest gcc 4.7.0 on centos 6.2?

    Thank you

  • Answers
  • Ярослав Рахматуллин

    If you can't find any official or unofficial RPMs for CentOS 6.2 you could try an RPM intended for other systems that are reasonably similar such as Fedora. This will not always work because the versions of shared libraries (run-time dependencies) for the target system will not necessarily correspond with the ones on your system.

    Building your own binaries is also an option. To do that you'll have to install the dependencies, run the configuration scripts and the automated compilation process and finally move the binaries to the /bin and /usr/lib folders of your system.

    The downside is the uninstall process is messy, unless you keep track of what is installed or retain the source folder (so make uninstall is available).

    Manual compilation of gcc is outlined on gcc.gnu.org

  • Thomas M

    Compiling gcc yourself is definitely an option. It is not too hard; I managed to compile gcc 4.8.1 on RHEL 5.9 following the link Ярослав Рахматуллин mentioned. I had to download mpfr (3.1.2, http://www.mpfr.org/), gmp (5.1.2, http://gmplib.org/) and mpc (1.0.1, http://www.multiprecision.org/) as dependencies.

    Especially useful tips derived from the Manual Compilation document: * unpack the mpfr, gmp and mpc sources into your gcc source directory and link them like this: ln -s mpfr-3.1.2 mpfr ; ln -s gmp-5.1.2 gmp ; ln -s mpc-1.0.1 mpc. * use out-of-source building (e.g. on the same level as your gcc-4.8.1 source dir resides: mkdir gcc-build ; cd gcc-build ; ../gcc-4.8.1/configure --prefix=/home/user/usr)

    The actual compilation of the whole compiler collection took ages even though I used 10 processors for parallel building.

    As suggested by Ярослав Рахматуллин, in case your installation directory (prefix) already contains other compiled programs, you might want to "record" the contents of it before and after doing 'make install' doing something like this:

    'find /home/user/usr > state.before ; make install ; find /home/user/usr > state.after'

    so you could compare the two files and delete the differences, should it ever be necessary to remove the new gcc (I must note though, that I personally have not tried this method, but rather keep the build directory to be able to do 'make uninstall').

    Be sure to adjust your PATH variable to include /home/user/usr/bin.


  • Related Question

    linux - Your GStreamer installation is missing a plug-in
  • alexus

    I'm having this issue with my music player (Rhythmbox Music Player) on my Linux (SL)

    it says:

    Couldn't start playback
    Your GStreamer installation is missing a plug-in
    

    I have all plug-ins installed on my system

    [alexus@wcmisdlin02 ~]$ yum list gstreamer-plugins-*
    Loaded plugins: refresh-packagekit
    http://10.52.208.221/yum/extras/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host"
    Trying other mirror.
    Installed Packages
    gstreamer-plugins-bad-free.i686                                                                                0.10.19-2.el6                                                                   @sl                                          
    gstreamer-plugins-bad-free.x86_64                                                                              0.10.19-2.el6                                                                   @anaconda-ScientificLinux-201107271550.x86_64
    gstreamer-plugins-bad-free-extras.i686                                                                         0.10.19-2.el6                                                                   @sl                                          
    gstreamer-plugins-bad-free-extras.x86_64                                                                       0.10.19-2.el6                                                                   @sl                                          
    gstreamer-plugins-base.i686                                                                                    0.10.29-1.el6                                                                   @sl                                          
    gstreamer-plugins-base.x86_64                                                                                  0.10.29-1.el6                                                                   @anaconda-ScientificLinux-201107271550.x86_64
    gstreamer-plugins-good.i686                                                                                    0.10.23-1.el6                                                                   @sl                                          
    gstreamer-plugins-good.x86_64                                                                                  0.10.23-1.el6                                                                   @anaconda-ScientificLinux-201107271550.x86_64
    Available Packages
    gstreamer-plugins-bad-free-devel.i686                                                                          0.10.19-2.el6                                                                   sl                                           
    gstreamer-plugins-bad-free-devel.x86_64                                                                        0.10.19-2.el6                                                                   sl                                           
    gstreamer-plugins-bad-free-devel-docs.x86_64                                                                   0.10.19-2.el6                                                                   sl                                           
    gstreamer-plugins-base-devel.i686                                                                              0.10.29-1.el6                                                                   sl                                           
    gstreamer-plugins-base-devel.x86_64                                                                            0.10.29-1.el6                                                                   sl                                           
    gstreamer-plugins-base-devel-docs.noarch                                                                       0.10.29-1.el6                                                                   sl                                           
    gstreamer-plugins-good-devel.i686                                                                              0.10.23-1.el6                                                                   sl                                           
    gstreamer-plugins-good-devel.x86_64                                                                            0.10.23-1.el6                                                                   sl                                           
    [alexus@wcmisdlin02 ~]$ 
    

    the only packages that are missing is devel packages... any ideas?


  • Related Answers
  • alexus

    this is what was missing...

    [alexus@wcmisdlin02 ~]$ sudo tail -1 /var/log/yum.log 
    Nov 15 12:43:38 Installed: gstreamer-ffmpeg-0.10.11-1.el6.rf.x86_64
    [alexus@wcmisdlin02 ~]$