Linux CentOS 6.5 manual upgrade gcc to gcc 6.1.0

  • 2020-05-12 06:39:21
  • OfStack

It has been several years since I entered the age of the code farmer. I didn't have the habit of writing blog posts, and I didn't record many things I used, but I forgot them later. When I needed to use them, I kept going to baidu google1, which cost me time and energy. (enough with that)

Nodejs: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++). Directly yum update gcc cannot be upgraded to 4.8, and then it can only be handled manually.

To start, if linux has the wget command installed:


wget http://ftp.gnu.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.gz
tar -zvxf gcc-6.1.0.tar.gz --directory=/usr/local/
cd /usr/local/gcc-6.1.0
./contrib/download_prerequisites 
mkdir build && cd build 
../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib 
make && make install

If it is installed on a virtual machine, it may take 3-4 hours.

What if if, what if your linux is not working, you don't have the wget command installed, or you can't access the exnet?? Read on:

Good to download the latest gcc (http: / / ftp. gnu. org gnu/gcc /), I use gcc - 6.1.0. tar. gz, through ftp upload Linux, extract:


tar -zvxf gcc-6.1.0.tar.gz --directory=/usr/local/
cd /usr/local/gcc-6.1.0

Then open the./contrib/download_prerequisites file with vi to see which dependency packages you currently download for gcc. When you open it, you see the following:

From this, we also need to download gmp-4.3.2.tar.bz2, isl-0.15.tar.bz2, mpc-0.8.1.1.tar.gz, mpfr-2.4.2.tar.bz2. Download the dependency package, unzip it directly to /usr/local/ gcc-6.1.0 / directory, and then set the soft link:


ln -sf gmp-4.3.2 gmp
ln -sf isl-0.15 isl
ln -sf mpc-0.8.1 mpc
ln -sf mpfr-2.4.2 mpfr

Once set up, the installation can begin:


mkdir build && cd build 
../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib 
make && make install

Related articles: