欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 金融 > build gcc

build gcc

2025/3/14 22:51:32 来源:https://blog.csdn.net/eloudy/article/details/146015735  浏览:    关键词:build gcc

 1,下载源码

wget https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-4.1.0.tar.bz2
 wget https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
 wget https://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.2.1.tar.gz


 git clone --mirror https://github.com/gcc-mirror/gcc.git
 cd ./ex/
 git clone ../gcc.git
 cd gcc
 git checkout releases/gcc-12.2.0

2,编译

cd gmp-6.1.0 && \
./configure --prefix=/home/hanmeimei/ex_gcc/tmp1/local/gmp-6.1.0 && \
make -j && sudo make install && \
cd ..

cd mpfr-4.1.0 && \
./configure --prefix=/home/hanmeimei/ex_gcc/tmp1/local/mpfr-4.1.0 --with-gmp=/home/hanmeimei/ex_gcc/tmp1/local/gmp-6.1.0 && \
make -j && sudo  make install && \
cd ..

cd mpc-1.2.1 && \
./configure --prefix=/home/hanmeimei/ex_gcc/tmp1/local/mpc-1.2.1 --with-gmp=/home/hanmeimei/ex_gcc/tmp1/local/gmp-6.1.0 --with-mpfr=/home/hanmeimei/ex_gcc/tmp1/local/mpfr-4.1.0  && \
make -j && sudo make install && \
cd ..


cd gcc && \
./configure --prefix=/home/hanmeimei/ex_gcc/tmp1/local/gcc-12.2.0 --enable-checking=release  --disable-multilib --with-gmp=/home/hanmeimei/ex_gcc/tmp1/local/gmp-6.1.0 --with-mpfr=/home/hanmeimei/ex_gcc/tmp1/local/mpfr-4.1.0 --with-mpc=/home/hanmeimei/ex_gcc/tmp1/local/mpc-1.2.1 && \
make -j &&sudo make install    

3,检查

4, 在高版本系统中编译低版本 GCC

通常会出现如下类似的错误:

gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /lib/x86_64-linux-gnu/libicuuc.so.70)

这是使用 bootstrap 方式编译

step1. 准备环境


 

sudo apt-get update
sudo apt-get install build-essential bison flex texinfo

step2. 下载并解压 GCC 源码

wget https://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.gz
tar xf gcc-7.4.0.tar.gz
cd gcc-7.4.0

step3. 下载依赖

./contrib/download_prerequisites

step4. 配置和编译

mkdir build && cd build
../configure \--prefix=/opt/gcc-7.4.0 \--enable-languages=c,c++ \--disable-multilib \--with-boot-ldflags='-static-libstdc++ -static-libgcc' \--with-stage1-ldflags='-static-libstdc++ -static-libgcc'make BOOT_CFLAGS='-O2' bootstrap -j$(nproc)
sudo make install

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词