Skip to content

Instantly share code, notes, and snippets.

@jdhao
Last active February 20, 2024 08:46
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save jdhao/e3fd77d51f3a95684d2b3354fc61b2ab to your computer and use it in GitHub Desktop.
Save jdhao/e3fd77d51f3a95684d2b3354fc61b2ab to your computer and use it in GitHub Desktop.
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
@jdhao
Copy link
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.

@eggybot
Copy link

eggybot commented Sep 21, 2021

@jdhao
do I need to add this in my profile?

export PATH=/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH

or optional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment