gcc 编译安装 12.4.0
安装 gcc-12.4.0
- 第1步,安装gcc编译器以支持c++11,否则后面会报错
configure: error: *** A compiler with support for C++11 language features is required.
yum install -y gcc-c++ gcc
yum install -y bzip2
curl -sL http://iso.sqlfans.cn/gcc/m4-1.4.19.tar.gz -o /opt/m4-1.4.19.tar.gz
tar -zxvf /opt/m4-1.4.19.tar.gz -C /opt/
cd /opt/m4-1.4.19
./configure --prefix=/usr/local/m4/1.4.19
make -j4
make install
export PATH=/usr/local/m4/1.4.19/bin:$PATH
curl -sL http://iso.sqlfans.cn/gcc/gmp-6.2.1.tar.bz2 -o /opt/gmp-6.2.1.tar.bz2
tar -jxvf /opt/gmp-6.2.1.tar.bz2 -C /opt/
cd /opt/gmp-6.2.1
./configure --prefix=/usr/local/gmp/6.2.1
make -j4
make check
make install
curl -sL http://iso.sqlfans.cn/gcc/mpfr-4.1.0.tar.bz2 -o /opt/mpfr-4.1.0.tar.bz2
tar -jxvf /opt/mpfr-4.1.0.tar.bz2 -C /opt/
cd /opt/mpfr-4.1.0
./configure --prefix=/usr/local/mpfr/4.1.0 --with-gmp=/usr/local/gmp/6.2.1
make -j4
make check
make install
curl -sL http://iso.sqlfans.cn/gcc/mpc-1.2.1.tar.gz -o /opt/mpc-1.2.1.tar.gz
tar -zxvf /opt/mpc-1.2.1.tar.gz -C /opt/
cd /opt/mpc-1.2.1
./configure --prefix=/usr/local/mpc/1.2.1 --with-gmp=/usr/local/gmp/6.2.1 --with-mpfr=/usr/local/mpfr/4.1.0
make -j4
make check
make install
curl -sL http://iso.sqlfans.cn/gcc/isl-0.24.tar.bz2 -o /opt/isl-0.24.tar.bz2
tar -jxvf /opt/isl-0.24.tar.bz2 -C /opt/
cd /opt/isl-0.24
./configure --prefix=/usr/local/isl/0.24 --with-gmp-prefix=/usr/local/gmp/6.2.1
make -j4
make check
make install
- 第7步,安装 gcc-12.4.0(注:4C16G虚机执行
make -j4
耗时57分)
ln -s /usr/local/isl/0.24/lib/libisl.so.23 /usr/lib64/libisl.so.23
ln -s /usr/local/mpfr/4.1.0/lib/libmpfr.so.6 /usr/lib64/libmpfr.so.6
curl -sL http://iso.sqlfans.cn/gcc/gcc-12.4.0.tar.gz -o /opt/gcc-12.4.0.tar.gz
tar -zxvf /opt/gcc-12.4.0.tar.gz -C /opt/ > /dev/null
cd /opt/gcc-12.4.0
./configure --prefix=/usr/local/gcc/12.4.0 \
--enable-threads=posix --enable-languages=c,c++,fortran --disable-checking --disable-multilib --disable-multilib --disable-libcc1cd \
--with-gmp=/usr/local/gmp/6.2.1 --with-mpfr=/usr/local/mpfr/4.1.0 --with-mpc=/usr/local/mpc/1.2.1 --with-isl=/usr/local/isl/0.24
make -j4
make install
echo 'export PATH=/usr/local/gcc/12.4.0/bin:$PATH' > /etc/profile.d/gcc.sh
source /etc/profile.d/gcc.sh
gcc --version