Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Build GCC 4.9.2 for C/C++ on CentOS 7
sudo yum install libmpc-devel mpfr-devel gmp-devel
cd ~/Downloads
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O
tar xvfj gcc-4.9.2.tar.bz2
cd gcc-4.9.2
./configure --disable-multilib --enable-languages=c,c++
make -j 4
make install
@92hackers

This comment has been minimized.

Copy link

92hackers commented Nov 9, 2015

thanks a lot

@chiangqiqi

This comment has been minimized.

Copy link

chiangqiqi commented Mar 14, 2016

this save my day

@virusme

This comment has been minimized.

Copy link

virusme commented May 13, 2016

Thank you!

@planetkr

This comment has been minimized.

Copy link

planetkr commented Jul 27, 2016

thank you!

@ankitsablok89

This comment has been minimized.

Copy link

ankitsablok89 commented Oct 21, 2016

Also if you encounter any issues like configure error : no C compiler found on $PATH then you can run the following command on centOS/Redhat

yum groupinstall "Development tools"

awesome post, helped me a lot

@marquessbr

This comment has been minimized.

Copy link

marquessbr commented Nov 12, 2016

ok, I can got it working, so how I can upgrade the cc compiler, because see below my console:

gcc --version

gcc (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cc --version

cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

thanks

@lucamosca1

This comment has been minimized.

Copy link

lucamosca1 commented Nov 25, 2016

Hi there, is it working also on amazon linux for newer version of gcc compiler?

@mmetince

This comment has been minimized.

Copy link

mmetince commented Dec 5, 2016

Gimme one reason why you forced us to use -j 4 ? I've been sitting in front of computer for a hour even though I've 16 CPU 30gb RAM. :(

@ibrahimnegm2011

This comment has been minimized.

Copy link

ibrahimnegm2011 commented Dec 17, 2016

Thanks a lot and for @ankitsablok89

@fahadmehar

This comment has been minimized.

Copy link

fahadmehar commented Jan 22, 2017

configure: error: Upgrade your compiler. GCC 4.7+ and Clang 3.2+ are known to work.

I wanted to install ZNC i am using Centos 6 64BIT... Please help me to fix this error. Thanks

@JBandassociate

This comment has been minimized.

Copy link

JBandassociate commented Apr 21, 2017

This is a bit silly, why not just --j. At least then no matter what hardware you have, make will use it to its capacity. unless doing other jobs, but this is a big job and will take hours with 4cpu.

@ElinhoPP

This comment has been minimized.

Copy link

ElinhoPP commented Jun 16, 2017

[root@Talesofmidigard gcc-4.9.2]# make -j 4
make: *** No targets specified and no makefile found. Stop.
[root@Talesofmidigard gcc-4.9.2]#

@nigelSaysHesHappy

This comment has been minimized.

Copy link

nigelSaysHesHappy commented Oct 24, 2017

So I managed to install this successfully, and was compiling code fine, but to make the compiled code run, I had to add "/usr/local/lib64/" to the ls.so.conf. Everything was perfect! But then after a reboot gcc reverted back to version 4.8.5 again... Even after recompiling and reinstalling I cannot get 4.9.2 to work anymore. Any ideas?

@xuesongbj

This comment has been minimized.

Copy link

xuesongbj commented Oct 25, 2017

For Red Hat and Fedora based systems, run the following command:

[root@x.xx.x] # sudo yum install gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel

This will install the GNU multiple-precision (MP) libraries for integer, floating point, and complex numbers.

@abitofalchemy

This comment has been minimized.

Copy link

abitofalchemy commented Feb 14, 2018

./configure command still complains:

checking whether /usr/local/bin/g++ supports C++14 features with -std=gnu++14... no
checking whether /usr/local/bin/g++ supports C++14 features with -std=gnu++1y... no
configure: error: *** A compiler with support for C++14 language features is required.```
I tried the above recommendations and can't get past this.
@mohammadmoozeh

This comment has been minimized.

Copy link

mohammadmoozeh commented Apr 30, 2018

thanks a lot

@u2tope

This comment has been minimized.

Copy link

u2tope commented Jun 14, 2018

Thanks. Save my day

But -j 4?... took hours for just 4 cpu.
I used --j instead like @JBandassociate indicated

@nikorose87

This comment has been minimized.

Copy link

nikorose87 commented Jun 19, 2018

Thanks!

@meetme2meat

This comment has been minimized.

Copy link

meetme2meat commented Sep 8, 2018

It takes infinity to build and install 😮

@claud-kim

This comment has been minimized.

Copy link

claud-kim commented Oct 22, 2018

@leungi

This comment has been minimized.

Copy link

leungi commented Aug 26, 2019

Life saver!

Works on Red Hat Enterprise Linux Server release 7.3 (Maipo).

@leungi

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.