当前位置: 首页 > news >正文

如何安装GCC?


layout: post
title: 如何安装GCC?
date: 2022-09-02 22:15:00
comments: true
description:
tags: post
categories: linux

安装GCC

./configure --prefix=/path/to/gcc
make
make install

相信大家在Linux下安装GCC都是一个难忘的回忆。笔者也经历过缺依赖,编好几个小时才发现错误。

重读文档

文档中描述,安装GCC是有几个必要依赖的,它们是GMP, MPFR and MPC。

If it provides sufficiently recent versions, use your OS package management system to install the support libraries in standard system locations. For Debian-based systems, including Ubuntu, you should install the packages libgmp-dev, libmpfr-dev and libmpc-dev. For RPM-based systems, including Fedora and SUSE, you should install gmp-devel, mpfr-devel and libmpc-devel (or mpc-devel on SUSE) packages. The packages will install the libraries and headers in standard system directories so they can be found automatically when building GCC.

Alternatively, after extracting the GCC source archive, simply run the ./contrib/download_prerequisites script in the GCC source directory. That will download the support libraries and create symlinks, causing them to be built automatically as part of the GCC build process. Set GRAPHITE_LOOP_OPT=no in the script if you want to build GCC without ISL, which is only needed for the optional Graphite loop optimizations.

The difficult way, which is not recommended, is to download the sources for GMP, MPFR and MPC, then configure and install each of them in non-standard locations, then configure GCC with --with-gmp=/some/silly/path/gmp --with-mpfr=/some/silly/path/mpfr --with-mpc=/some/silly/path/mpc, then be forced to set LD_LIBRARY_PATH=/some/silly/path/gmp:/some/silly/path/mpfr:/some/silly/path/mpc/lib in your environment forever. This is silly and causes major problems for anyone who doesn’t understand how dynamic linkers find libraries at runtime. Do not do this. If building GCC fails when using any of the --with-gmp or --with-mpfr or --with-mpc options then you probably shouldn’t be using them.

如上面摘抄的所示,有三种方式可以将依赖准备好。

  • 第一种是使用系统自带的包管理器,将依赖安装,这时这些依赖都将安装到系统默认的目录下;
  • 第二种是执行GCC目录下的./contrib/download_prerequisites 脚本,将依赖的源码包下载下来,随GCC一起编译安装;
  • 第三种,也是最难,不推荐的方式,就是分别安装好,然后以--with-gmp=/some/silly/path/gmp --with-mpfr=/some/silly/path/mpfr --with-mpc=/some/silly/path/mpc的这种方式指定。

其他自动化方法

  1. 系统的包管理器安装GCC
    发行版的系统,均提供了自己的包管理器。CentOS提供了yum,Ubuntu提供了apt等等。使用操作系统自带的包管理器,可以很方便地将GCC安装上。缺点是,它只能安装包管理器仓库里提供的版本,不能随心所欲。

  2. 使用spack包管理器
    spack包管理器是一个强大的包管理器。安装开源库是一个NP问题,靠人工解决依赖很麻烦,像spack这种提前定义好依赖关系,自动生成单向无环图,可以一键完成人工要画几小时、几天甚至无法完成的依赖关系安装。

  3. easybuild包管理器
    同spack一样,easybuild也是类似功能的包管理器。

相关文章:

  • latex(overleaf)制作ppt(演示文稿)笔记
  • C#:实现将整数转换为二进制表示形式的字符串算法(附完整源码)
  • .NET C#版本和.NET版本以及VS版本的对应关系
  • C#:实现KochSnowflake科赫雪花算法(附完整源码)
  • vim YouCompleteMe报错:version `GLIBCXX_3.4.20‘ not found 解决方法
  • 数字藏品和NFT有什么区别?
  • 【Python零基础入门篇 · 4】:字符串的运算符、下标和切片
  • 【ElasticSearch】6亿文档存储的ES集群调优实战
  • Ubuntu16/04安装python3.9版本
  • java基于web的工资管理系统
  • cuda-gdb 支持内置变量的实现机制
  • 【云原生 · Kubernetes】kubernetes v1.23.3 二进制部署(三)
  • 微服务项目:尚融宝(13)(前端平台:搭建管理平台前端程序)
  • 【C++】模板初阶,了解函数模板和类模板的使用一些可能出现的问题
  • 微服务项目:尚融宝(14)(前端平台:尚融宝管理系统路由配置)
  • [译]前端离线指南(上)
  • 【跃迁之路】【669天】程序员高效学习方法论探索系列(实验阶段426-2018.12.13)...
  • 230. Kth Smallest Element in a BST
  • MySQL用户中的%到底包不包括localhost?
  • MySQL主从复制读写分离及奇怪的问题
  • Netty源码解析1-Buffer
  • Solarized Scheme
  • UMLCHINA 首席专家潘加宇鼎力推荐
  • 从tcpdump抓包看TCP/IP协议
  • 复习Javascript专题(四):js中的深浅拷贝
  • 机器学习 vs. 深度学习
  • 开发基于以太坊智能合约的DApp
  • 坑!为什么View.startAnimation不起作用?
  • 理解IaaS, PaaS, SaaS等云模型 (Cloud Models)
  • 前端攻城师
  • 浅析微信支付:申请退款、退款回调接口、查询退款
  • 数据结构java版之冒泡排序及优化
  • 小程序button引导用户授权
  • 一份游戏开发学习路线
  • 主流的CSS水平和垂直居中技术大全
  • 【运维趟坑回忆录 开篇】初入初创, 一脸懵
  • hi-nginx-1.3.4编译安装
  • 翻译 | The Principles of OOD 面向对象设计原则
  • ​如何防止网络攻击?
  • $con= MySQL有关填空题_2015年计算机二级考试《MySQL》提高练习题(10)
  • (07)Hive——窗口函数详解
  • (1)Android开发优化---------UI优化
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (floyd+补集) poj 3275
  • (NSDate) 时间 (time )比较
  • (react踩过的坑)antd 如何同时获取一个select 的value和 label值
  • (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY)讲解
  • (八)Docker网络跨主机通讯vxlan和vlan
  • (附源码)spring boot北京冬奥会志愿者报名系统 毕业设计 150947
  • (十)c52学习之旅-定时器实验
  • (一)SpringBoot3---尚硅谷总结
  • (转)http协议
  • (转)linux自定义开机启动服务和chkconfig使用方法
  • (转)winform之ListView
  • * 论文笔记 【Wide Deep Learning for Recommender Systems】