当前位置:首页 » 《随便一记》 » 正文

linux离线手动安装升级gcc

16 人参与  2024年04月14日 08:01  分类 : 《随便一记》  评论

点击全文阅读


目录

前言一、下载源码二、离线安装使用步骤1.解压2.安装2.1安装依赖包2.2安装gcc2.3配置gcc环境 三、源码安装gcc各种情况的解决1. 未找到命令1.1 XXX is missing on your system.1.2 解决方法重新touch编译文件安装对应命令

前言

GCC可以用来编译C/C++、FORTRAN、JAVA、OBJC、ADA等语言 的程序,可根据需要选择安装支持的语言。
查看当前gcc版本:

gcc --version

一、下载源码

gcc-7.2.0版本:https://ftp.gnu.org/gnu/gcc/
下载依赖,共依赖四个工具gmp、isl、mpc、mpfr
gmp-6.1.0版本:https://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.bz2
isl-0.16版本: http://www.mirrorservice.org/sites/sourceware.org/pub/gcc/infrastructure
mpc-1.0.3版本 :https://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
mpfr-3.1.4版本:https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.gz

提示:对应不同版本的gcc,对应的依赖版本可能也不一样,具体版本查看gcc-7.2.0/contrib/download_prerequisites

有网络的Linux 安装 gcc 的时候直接执行 ./contrib/download_prerequisites,自带下载安装依赖:mpfr、mpc、gmp 等

二、离线安装使用步骤

1.解压

tar -zxvf gcc-7.2.0.tar.gztar -xf mpfr-3.1.4.tar.gztar -xf isl-0.16.tar.bz2tar -xf mpc-1.0.3.tar.gztar -xf gmp-6.1.0.tar.bz2

2.安装

2.1安装依赖包

cd gmp-6.1.0  && ./configure && make && make installcd mpfr-3.1.4 && ./configure && make && make installcd isl-0.16   && ./configure && make && make installcd mpc-1.0.3  && ./configure && make && make install

确认 gmp, mpfr, mpc 等包已经安装,并且版本正确

rpm -qa | grep gmprpm -qa | grep mpfrrpm -qa | grep mpc

2.2安装gcc

查看linux版本 uname -a
我的版本是
aarch64 GNU/Linux

#运行configure时加上对应版本的信息,不然可能会报错,linux版本不同会有所区别
–build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu

mkdir build   //不能在source目录下configure cd build                          $PWD/../gcc-7.2.0/configure --prefix=/usr/local/gcc_deps --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu   // 不运行这个$PWD/../gcc-7.2.0/configure --prefix=usr/local/gcc_depsmakemake checkmake install

编译好后,gcc安装到了usr/local/gcc_deps,内容如下
在这里插入图片描述

2.3配置gcc环境

如果安装位置不是在/usr,需要配置对应的环境

编译gcc时configure命令把–prefix=usr/local/gcc_deps改为–prefix=/usr,gcc默认配置在/usr下,直接替换了原先的gcc版本,出了问题难恢复。
安装在其他目录下,需安装后对应配置gcc环境

在命令行中设置

export PATH=/usr/local/gcc_deps/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/gcc_deps/lib64:$LD_LIBRARY_PATH

永久设置

可以在.bashrc或.profile等文件中永久设置LD_LIBRARY_PATH环境变量:

echo 'export LD_LIBRARY_PATH=/usr/local/lib' >> ~/.bashrc

三、源码安装gcc各种情况的解决

1. 未找到命令

1.1 XXX is missing on your system.

...行81: makeinfo:未找到命令WARNING: 'makeinfo' is missing on your system.         You should only need it if you modified a '.texi' file, or         any other file indirectly affecting the aspect of the manual.         You might want to install the Texinfo package:         <https://www.gnu.org/software/texinfo/>         The spurious makeinfo call might also be the consequence of         using a buggy 'make' (AIX, DU, IRIX), in which case you might         want to install GNU make:         <https://www.gnu.org/software/make/>         ...

1.2 解决方法

重新touch编译文件

WARNING: 'aclocal-1.14' is missing on your system.You should only need it if you modified 'acinclude.m4' or 'configure.ac' or m4 files included by 'configure.ac'. The 'aclocal' program is part of the GNU Automake package: It also requires GNU Autoconf, GNU m4 and Perl in order to run: make[1]: *** [aclocal.m4] Error 127

系统中没有找到’aclocal-1.14’,但存在1.15版本的aclocal。
可以试一下重新touch几个编译文件

touch configure.ac aclocal.m4 configure Makefile.am Makefile.in

安装对应命令

下载路径:https://ftp.gnu.org/gnu/texinfo/

tar zxvf texinfo-5.2.tar.gzcd texinfo-5.2./configure --prefix=/usrmakemake checkmake install

makeinfo
下载路径:https://ftp.gnu.org/gnu/texinfo/

help2man: can’t get `–help’ info from automake-1.15 Try
参考链接:https://www.jianshu.com/p/31a30a969a82

WARNING: ‘aclocal-1.16’ is missing on your system
参考链接:https://blog.csdn.net/poem_2010/article/details/102527733


点击全文阅读


本文链接:http://zhangshiyu.com/post/95050.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1