Ubuntu20安装gcc6.3.0

安装前与下载

gcc的源码下载网址:http://ftp.gnu.org/gnu/gcc/
我下载的时候发现下载的特别慢,于是我复制了网址到手机浏览器下载,速度就快了。

安装gcc必备的几个包:m4、gmp、mpfr、mpc
第一个包可以通过apt install安装,输入下面命令。可以下载后三个压缩包。

./contrib/download_prerequisites

注意:上述四个软件包一定要按照顺序安装。

安装gmp-4.3.2

cd gcc-6.3.0/gmp-4.3.2   #进入文件夹
./configure --prefix=/usr/local/gmp-4.3.2
make
sudo make install

安装mpfr-2.4.2

cd gcc-6.3.0/mpfr-2.4.2/   #进入文件夹
./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2
make
sudo make install

安装mpc-0.8.1

cd gcc-6.3.0/mpc-0.8.1   #进入文件夹
./configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
make
sudo make install

安装gcc

cd gcc-6.3.0/   #进入文件夹
sudo ../gcc-6.3.0/configure --prefix=/usr/local/gcc-6.3.0 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
make
sudo make install

make的时间特别长,我用了近2个小时。

遇到的一些问题

make时遇到的问题
  1. configure: error: cannot compute suffix of object files: cannot compile
    解决办法: 将gmp、mpfr、mpc添加进系统变量
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib
source /etc/profile
  1. error: dereferencing pointer to incomplete type ‘struct ucontext’
    解决办法:
    修改 md-unwind-support.h 文件的第 61 行,其中该文件位于 ./x86_64-pc-linux-gnu/libgcc 目录下。跳转到第 61 行,修改·struct ucontext *uc_ = context->cfa; 中的ucontextucontext_t
struct ucontext_t *uc_ = context->cfa;

重新执行 make。
3. /libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:158:23: fatal error: sys/ustat.h: No such file or directory
解决办法:
找到这个文件/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc,删除第158,#include <sys/ustat.h> .
找到251行,在你的代码里,注释掉下面代码第一行。把// 包含的内容加进去。

  //unsigned struct_ustat_sz = sizeof(struct ustat);
//

// Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
  // has been removed from glibc 2.28.
#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
  || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
  || defined(__x86_64__)
#define SIZEOF_STRUCT_USTAT 32
#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
  || defined(__powerpc__) || defined(__s390__)
#define SIZEOF_STRUCT_USTAT 20
#else
#error Unknown size of struct ustat
#endif
  unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;

//
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值