GCC源码编译
Posted yahengwang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GCC源码编译相关的知识,希望对你有一定的参考价值。
1. gcc源码下载
ftp://gcc.gnu.org/pub/gcc/releases/
[[email protected] ~] wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-8.2.0/gcc-8.2.0.tar.gz [[email protected] ~] tar zxvf gcc-8.2.0.tar.gz
下载你所需要的GCC版本。
2. 下载gcc依赖库源码
gmp ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
mpc ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
mpfr ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
[[email protected] ~] wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [[email protected] ~] tar jxvf gmp-6.1.0.tar.bz2 [[email protected] ~] tar zxvf mpc-1.0.3.tar.gz [[email protected] ~] tar jxvf mpfr-3.1.4.tar.bz2 [[email protected] ~] cd ~/gmp-6.1.0 [[email protected] ~] ./configure --prefix=/usr/local/gmp [[email protected] ~] make && make install [[email protected] ~] cd ~/mpc-1.0.3 [[email protected] ~] ./configure --prefix=/usr/local/mpc [[email protected] ~] make && make install [[email protected] ~] cd ~/mpfr-3.1.4 [[email protected] ~] ./configure --prefix=/usr/local/mpfr [[email protected] ~] make && make install [[email protected] ~] export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/ [[email protected] ~] cd ~/gcc-8.2.0 [[email protected] ~] ./configure --prefix=/usr/local/gcc --with-gmp=/usr/local/gmp/ --with-mpfr=/usr/local/mpfr/ --with-mpc=/usr/local/mpc/ --with-system-zlib --disable-multilib [[email protected] ~] make && make install
3. 注意点
make时遇到:
checking for suffix of object files... configure: error: in `/home/yhwang/gcc-8.2/gcc-8.2.0/x86_64-linux-gnu/libgcc‘:
configure: error: cannot compute suffix of object files: cannot compile
See `config.log‘ for more details.
make[2]: *** [configure-stage1-target-libgcc] 错误 1
make[2]:正在离开目录 `/home/yhwang/gcc-8.2/gcc-8.2.0‘
make[1]: *** [stage1-bubble] 错误 2
make[1]:正在离开目录 `/home/yhwang/gcc-8.2/gcc-8.2.0‘
make: *** [all] 错误 2
然后就停下了,在编译之前需要输入如下语句
[[email protected] ~] export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/
然后
[[email protected] ~] make && make install
4. 检查gcc版本
[[email protected] ~] gcc -v [[email protected] ~] g++ -v
以上是关于GCC源码编译的主要内容,如果未能解决你的问题,请参考以下文章