Fork me on GitHub

【C++】编译安装 gcc10

1. 下载

打开 ftp 地址

ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases

选择某一个版本的 gcc,本文选择 gcc10.2.0

 

完整的下载链接如下

ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-10.2.0/gcc-10.2.0.tar.gz

2. 编译

tar -xvzf gcc-10.2.0.tar.gz
cd gcc-10.2.0
./contrib/download_prerequisites
./configure \
    --enable-bootstrap \
    --enable-languages=c,c++,fortran,lto \
    --with-bugurl=http://bugzilla.redhat.com/bugzilla \
    --enable-shared \
    --enable-threads=posix \
    --enable-checking=release \
    --disable-multilib \
    --with-system-zlib \
    --enable-__cxa_atexit \
    --disable-libunwind-exceptions \
    --enable-gnu-unique-object \
    --enable-linker-build-id \
    --with-gcc-major-version-only \
    --enable-plugin \
    --with-linker-hash-style=gnu \
    --enable-initfini-array \
    --enable-libmpx \
    --enable-gnu-indirect-function \
    --with-tune=generic \
    --build=x86_64-redhat-linux
make -j4
sudo make install
sudo sh -c 'echo /usr/local/lib > /etc/ld.so.conf.d/1-gcc.conf'
sudo sh -c 'echo /usr/local/lib64 >> /etc/ld.so.conf.d/1-gcc.conf'
sudo ldconfig -v

 

arm 环境 aarch64

./configure \
    --enable-bootstrap \
    --enable-languages=c,c++,fortran,lto \
    --with-bugurl=http://bugzilla.redhat.com/bugzilla \
    --enable-shared \
    --enable-threads=posix \
    --enable-checking=release \
    --disable-multilib \
    --with-system-zlib \
    --enable-__cxa_atexit \
    --disable-libunwind-exceptions \
    --enable-gnu-unique-object \
    --enable-linker-build-id \
    --with-gcc-major-version-only \
    --enable-plugin \
    --with-linker-hash-style=gnu \
    --enable-initfini-array \
    --enable-libmpx \
    --enable-gnu-indirect-function \
    --build=aarch64-unknown-linux-gnu

  

3. 验证

g++ -dM -E -x c++ /dev/null | grep -F __cplusplus

  

posted @ 2022-06-14 20:13  Mr.YF  阅读(438)  评论(0编辑  收藏  举报