Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The script will install GCC 5.4.0 on your CentOS 7 system, make sure you have root right. See https://jdhao.github.io/2017/09/04/install-gcc-newer-version-on-centos/ for more details.
echo "Downloading gcc source files..."
curl https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2 -O
echo "extracting files..."
tar xvfj gcc-5.4.0.tar.bz2
echo "Installing dependencies..."
yum -y install gmp-devel mpfr-devel libmpc-devel
echo "Configure and install..."
mkdir gcc-5.4.0-build
cd gcc-5.4.0-build
../gcc-5.4.0/configure --enable-languages=c,c++ --disable-multilib
make -j$(nproc) && make install
@AK-ayush

This comment has been minimized.

Copy link

AK-ayush commented Nov 16, 2018

In my case, this script is giving error:

configure: error: error verifying int64_t uses long long 
make[2]: *** [configure-stage1-gcc] Error 1

I solved this by installing gcc-c++

yum install gcc-c++ -y
@miamartin8

This comment has been minimized.

Copy link

miamartin8 commented Jan 7, 2020

@jdhao thank you for posting this...it was very helpful! Now I need to downgrade back to gcc 4.8, but I am unable to. Any advice on how to do so?

@jdhao

This comment has been minimized.

Copy link
Owner Author

jdhao commented Jan 8, 2020

@miamartin8, I think you can just install gcc 4.8. Multitiple gcc installation is fine, you can just add --prefix /gcc/install/path to indicate where you want to install it instead of the default location. After installation, you can manipulate your $PATH variable to indicate which gcc you want to use.

Ref: https://askubuntu.com/questions/891835/what-does-prefix-do-exactly-when-used-in-configure

@knasim

This comment has been minimized.

Copy link

knasim commented Jan 22, 2020

too dependent on yum can be problematic since it requires sudo.

@jdhao

This comment has been minimized.

Copy link
Owner Author

jdhao commented Jan 23, 2020

@knasim, yeah, that is true. If you do not have sudo rights, you also have to compile the dependencies from source.
At the time of writing this script, I had sudo rights, so I just installed the dependency via yum.

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.