English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CentOS in Linux 6.5 Manually upgrade gcc to gcc-6.1.0

Ever since I entered the era of coding, it has been several years, and I have never had the habit of writing blogs. Many things used were not recorded, and later I forgot. When I need to use them, I keep searching on Baidu and Google, which takes time and energy, and it is not necessarily possible to find a satisfactory answer. Therefore, I start a blog to record it. (No more nonsense)

  Today, when installing Nodejs from source on the company server, I encountered an error WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++) Directly yum update gcc cannot upgrade to4.8,then you can only manually handle it.

  Start, if the Linux system 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 you are installing on a virtual machine, you may need3-4hours, be patient and wait, young man。。。

  If unfortunately, your Linux does not have the wget command installed, or you cannot access the internet, what should you do???Keep reading below:

  First, download the latest gcc (http://ftp.gnu.org/gnu/gcc/),I use gcc-6.1.0.tar.gz, upload it to Linux via ftp, and unzip it:  

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

  Then use vi to open ./contrib/download_prerequisites file to check which dependency packages the currently downloaded gcc needs. After opening, you will see the following content:

  Therefore, we also need to download gmp-4.3.2.tar.bz2, isl-0.15.tar.bz2, mpc-0.8.1.tar.gz, mpfr-2.4.2.tar.bz2, note that the dependency package must be the specified version, otherwise problems may occur. After downloading the dependency package, directly extract it to/usr/local/gcc-6.1.0/ directory, then set up the symbolic 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

  After setting up, you can start the installation:

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

The following is what the editor introduces to everyone about CentOS in Linux 6.5 Manually upgrade gcc to gcc-6.1.0, hoping it will be helpful to everyone. If you have any questions, please leave a message, and the editor will reply to everyone in time. Here, I also want to express my heartfelt thanks to everyone for their support of the Yelling Tutorial website!

Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, does not edit the content manually, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (When reporting, please replace # with @ and provide relevant evidence. Once verified, this site will immediately delete the infringing content.)

You May Also Like