Home  >  Article  >  Backend Development  >  Example of how to upgrade gcc in linux

Example of how to upgrade gcc in linux

小云云
小云云Original
2018-03-17 09:12:492925browse


The original intention of GCC was to be a compiler specially written for the GNU operating system. The GNU system is completely free software. Here, "free" means that it respects the user's freedom. This article mainly shares with you examples of how to upgrade gcc in Linux. I hope it can help you.

wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2
tar -jxvf gcc-4.8.2.tar.bz2

Create a directory for storing compiled files

mkdir gcc-build-4.8.2
cd gcc-build-4.8.2

Generate Makefile file

../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib

Compile (note: this step is very time-consuming)

make -j4

make -j4

sudo make install

Restart and check the gcc version gcc -v Write a program segment test.cpp with C++11 features and use shared_ptr

//test.cpp
#include 
#include 
using namespace std;
int main()
{
      shared_ptr pInt(new int(10));
      cout < < *pInt << endl;
      return 0;
}

Verification

g++ -std=c++11 -o test test.cpp
./test

If you cannot find GLIBCXX_3.4.15 in libstdc++.so.6, please execute the following Command

cp /usr/local/lib64/libstdc++.so.6.0.18 /usr/lib64
rm -rf /usr/lib64/libstdc++.so.6
ln -s /usr/lib64/libstdc++.so.6.0.18 /usr/lib64/libstdc++.so.6

to check whether the link is

ll /usr/lib64/libstdc++.so.6
lrwxrwxrwx 1 root root 19  9月 29 12:48 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.18

Related recommendations:

lnmp - Doubts about PHP7 GCC PGO compilation

Make your PHP 7 faster GCC PGO

linux centos5.5 cannot install gcc for some unknown reason

The above is the detailed content of Example of how to upgrade gcc in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn