How to install gcc in centos 7 and gcc in centos 7
System Environment:Centos7.4
When Nodejs8.7 is installed today, a warning is reported:
WARNING: C ++ Compiler too old, need g ++ 4.9.4 or clang ++ 3.4.2 (CXX = g ++)
Then, check the version installed on your system: 4.8.5.
Okay, you can't use yum for upgrade. you can install it manually.
1. Select the version to be upgraded
Gcc ftp LIST
(I selected 5.4.0)
2. Obtain and decompress the installation package
Cd/usr/local/src
Wget https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2
Tar-jxvf gcc-5.4.0.tar.bz2
Note: bz2 is a compressed file format. If the file cannot be decompressed, install bzip2: yum-y install bzip2.
3. Go to the decompressed gcc folder and download the dependencies required for compilation.
Cd gcc-build-5.4.0
./Contrib/download_prerequisites
4. Create a folder to store compiled files
Mkdir gcc-build-5.4.0
Cd gcc-build-5.4.0
5. Generate Makefile
Make
Note: This process is very time-consuming. It takes about an hour for my 1-Core 1 GB memory.
Vi. Installation
Sudo make install
7. Restart the server and verify the version
Gcc-v
After waiting for so long, I finally succeeded. I'm very excited, right?
But!
After I executed the above code, I ran to compile nodejs and made a mistake:
/Usr/local/src/node-v8.7.0/out/Release/mksnapshot:/lib64/libstdc ++. so.6: version 'glibcxx _ 3.4.21 'not found (required by/usr/local/src/node-v8.7.0/out/Release/mksnapshot)
Compilation failed ~ Labor and Capital waited for 30 minutes
Okay, after all, the problem will be solved.
Cause: the generated dynamic library does not replace the gcc dynamic library of the old version during gcc upgrade.
Solution: Replace the dynamic library of the latest gcc version with the dynamic library of the old version in the system.
(1). Find the latest dynamic library generated during gcc Compilation
Find/-name "libstdc ++. so *"
(2) copy the found dynamic library libstdc ++. so.6.0.21 to/usr/lib64.
Cp/usr/local/src/gcc-5.4.0/gcc-build-5.4.0/stage1-x86_64-unknown-linux-gnu/libstdc ++-v3/src/. libs/libstdc ++. so.6.0.21/usr/lib64
(3) switch the working directory to/usr/lib64, delete the original soft connection, and direct the soft connection of the default Library to the latest dynamic library.
Cd/usr/lib64
Rm-rf libstdc ++. so.6
Ln-s libstdc ++. so.6.0.21 libstdc ++. so.6
This is the end of the job.
Reference link:
IT transcript