一、gcc下載
下載地址:https://ftp.gnu.org/gnu/gcc/
選擇想要下載的版本,然后解壓,查看 contrib/download_prerequisites 中的依賴。
以我下載的 gcc-7.3.0 為例,
二、安裝依賴包
【gmp】 https://ftp.gnu.org/gnu/gmp/
【isl】 https://gcc.gnu.org/pub/gcc/infrastructure/
【mpc】 https://ftp.gnu.org/gnu/mpc/
【mpfr】 https://ftp.gnu.org/gnu/mpfr/
2.1 安裝gmp
wget https://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.bz2
tar xjf gmp-6.1.0.tar.bz2
cd gmp-6.1.0/
./configure --prefix=/path-to-install/gmp
make -j32 && make install
2.2 安裝mpfr
wget https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.gz
tar xvf mpfr-3.1.4.tar.gz
cd mpfr-3.1.4/
./configure --prefix=/path-to-install/mpfr --with-gmp=/path-to-install/gmp
make -j32 && make install
2.2 安裝mpc
wget https://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
tar xvf mpc-1.0.3.tar.gz
cd mpc-1.0.3/
./configure --prefix=/path-to-install/mpc --with-gmp=/path-to-install/gmp --with-mpfr=/path-to-install/mpfr
make -j32 && make install
2.4 安裝isl
wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
tar xjf isl-0.16.1.tar.bz2
cd isl-0.16.1/
./configure --prefix=/path-to-install/isl --with-gmp-prefix=/path-to-install/gmp
make -j32 && make install
三、 安裝gcc
cd gcc-7.3.0/
./configure --prefix=/path-to-install/gcc \ --with-gmp=/path-to-install/gmp \--with-mpfr=/path-to-install/mpfr \--with-mpc=/path-to-install/mpc \--with-isl=/path-to-install/isl \--enable-checking=release \--enable-languages=c,c++ \--disable-multilib
make -j32 && make install
3.1 配置環境變量
修改 ~/.bashrc
export LD_LIBRARY_PATH=/path-to-install/isl/lib:/path-to-install/gcc/lib64:$LD_LIBRARY_PATH
export PATH=/path-to-install/gcc/bin:$PATH
export CC=/path-to-install/gcc/bin/gcc
export CXX=/path-to-install/gcc/bin/g++
然后 source ~/.bashrc
四、安裝cmake
wget http://www.cmake.org/files/v3.27/cmake-3.27.1.tar.gz
tar xf cmake-3.27.1.tar.gz
cd cmake-3.27.1
./configure --prefix=/path-to-install/cmake
make -j32 && make install
然后參考 3.1 修改 ~/.bashrc