In some cases, my Linux server cannot connect to the Internet while I have to upgrade the GCC on that server to use C++17 or higher. Unlike CMAKE, I have nowhere to download the prebuild binary version of the GCC. The only way is to upload all the necessary files and make them one by one.
Sounds boring. Here is what I did. I make notes about the steps incase I need it again.
0. Find a mirror
1. Download all related files
When you need to make GCC, you have to make some other libraries first. They are gmp-x.x.x.tar.gz
, mpfr-x.x.x-tar.gz
, mpc-x.x.x.tar.gz
and of course you need gcc-x.x.x.tar.gz
itself.
There are dependencies. Make sure to check the release date of all versions of libraries. The release date from early to late should be gmp
< mpfr
< mpc
< gcc
.
2. make gmp
1 | tar xzf gmp-x.x.x.tar.gz |
3. make mpfr
1 | tar xzf mpfr-x.x.x.tar.gz |
4. make mpc
1 | tar xzf mpc-x.x.x.tar.gz |
5. set LD_LIBRARY_PATH
1 | export LD_LIBRARY_PATH=/path/to/mpc-x.x.x/lib:/path/to/gmp-x.x.x/lib:/path/to/mpfr-x.x.x/lib:$LD_LIBRARY_PATH |
6. make gcc
1 | tar xzf gcc-x.x.x.tar.gz |
Be patient. It takes 4-8 hours.
7. many exports
1 | export PATH=/path/to/gcc-x.x.x/bin:$PATH |
8. Check if installed successfully
1 | gcc --version |
Now everything is finished. Congratulations.
FYI How to install cmake
Without Internet.
Go to CMake website and download file like this cmake-x.xx.x-linux-x86_64.tar.gz
1 | tar -xvf cmake-x.xx.x-linux-x86_64.tar.gz |