# yum install -y bzip2 gcc gcc-c++ # cd /usr/local/src/ # wget https://mirrors.aliyun.com/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz # tar -xzvf gcc-9.3.0.tar.gz # cd gcc-9.3.0/ # wget https://mirrors.aliyun.com/gnu/gmp/gmp-6.1.0.tar.bz2 # wget https://mirrors.aliyun.com/gnu/mpfr/mpfr-3.1.4.tar.bz2 # wget https://mirrors.aliyun.com/gnu/mpc/mpc-1.0.3.tar.gz # wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 # ./contrib/download_prerequisites # mkdir build && cd build # grep "^language=" ../gcc/*/config-lang.in # ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr # make -j 16 # make -j 16 install
查看gcc版本:
1 2 3 4 5 6 7 8
# ls /usr/lib64/libstdc++* /usr/lib64/libstdc++.a /usr/lib64/libstdc++fs.la /usr/lib64/libstdc++.so /usr/lib64/libstdc++.so.6.0.19 /usr/lib64/libstdc++.so.6.0.28-gdb.py /usr/lib64/libstdc++fs.a /usr/lib64/libstdc++.la /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.0.28 # gcc --version gcc (GCC) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
下载安装make:
下载地址:https://ftp.gnu.org/gnu/make/
1 2 3 4 5 6 7
# cd /usr/local/src/ # wget https://mirrors.aliyun.com/gnu/make/make-4.3.tar.gz # tar -xzvf make-4.3.tar.gz # cd make-4.3/ # mkdir build && cd build # ../configure --prefix=/usr # make -j 16 && make -j 16 install
查看make版本:
1 2 3 4 5 6 7
# make --version GNU Make 4.3 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
# cd /usr/local/src/ # wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.31.tar.gz # tar -xzvf glibc-2.31.tar.gz # cd glibc-2.31/ # cat INSTALL | grep -E "newer|later" this option if you want to compile the GNU C Library with a newer GCC 8 and binutils 2.29 or later. Note that when CET is enabled, x86-64 processors as well as Intel Pentium Pro or newer. to build without this option (for example, if building with a newer The tests (and later installation) use some pre-existing files of the * GNU 'make' 4.0 or newer * GCC 6.2 or newer building the GNU C Library, as newer compilers usually produce * GNU 'binutils' 2.25 or later * GNU 'texinfo' 4.7 or later * GNU 'bison' 2.7 or later * GNU 'sed' 3.02 or newer * Python 3.4 or later * GDB 7.8 or later with support for Python 2.7/3.4 or later * GNU 'gettext' 0.10.36 or later to have the header files from a 3.2 or newer kernel around for reference. (For the ia64 architecture, you need version 3.2.18 or newer # mkdir build && cd build # yum install -y python3 bison texinfo binutils # ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin --disable-sanity-checks --disable-werror # make -j 16 # make -j 16 install
忽略make install报错:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
collect2: error: ld returned 1 exit status Execution of gcc -B/usr/bin/ failed! The script has found some problems with your installation! Please read the FAQ and the README file and check the following: - Did you change the gcc specs file (necessary after upgrading from Linux libc5)? - Are there any symbolic links of the form libXXX.so to old libraries? Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong, libm.so should point to the newly installed glibc file - and there should be only one such link (check e.g. /lib and /usr/lib) You should restart this script from your build directory after you've fixed all problems! Btw. the script doesn't work if you're installing GNU libc not as your primary library! make[1]: *** [Makefile:120: install] Error 1 make[1]: Leaving directory '/usr/local/src/glibc-2.31' make: *** [Makefile:12: install] Error 2