标签:class 字段 系统 ash inf csdn nbsp bootstra boot
本文给出两种源码安装gcc7.3.0的方法。
依赖的环境安装到自建文件夹下,
给出下面操作中环境的安装文件夹:
/home/devilmaycry/anaconda3/mindspore_envs
这个路径可以按照个人情况进行设置的,只要下面均保持一致即可。
下文中修改 .bashrc 是指打开.bashrc :
vim ~/.bashrc
=======================================================================
1. 自动下载安装gcc的依赖环境: gmp, mpfr, mpc
下载gcc 7.3.0版本安装包,执行以下命令:
wget http://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
执行tar -xzf gcc-7.3.0.tar.gz
解压源码包。
执行cd gcc-7.3.0
,进入到源码包目录。
继续下面操作前清空系统内的环境变量:
export LIBRARY_PATH= export LD_LIBRARY_PATH= export C_INCLUDE_PATH= export CPLUS_INCLUDE_PATH=
运行以下命令,进行安装前的配置。
安装依赖环境:
./contrib/download_prerequisites
配置环境:
./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0 --enable-bootstrap -enable-threads=posix --enable-checking=release --enable-languages=c,c++ --disable-multilib
编译安装:
make && make install
=======================================================================
2. 源码安装gcc的依赖环境,gmp, mpfr, mpc
下载 gmp-6.1.2 mpfr-4.1.0 mpc-1.2.1
由于 gmp 依赖 m4, 因此我们先安装 m4 。
m4 下载安装:
下载地址:
http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.bz2
解压:
tar -jxvf m4-1.4.16.tar.bz2
修改m4_1.4.16下源文件中代码:(https://blog.csdn.net/weixin_34168880/article/details/91842744)
vi lib/stdio.in.h
查找字段:gets is a security hole
注释:
将_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 字段和他之前的注释 /* 一块注释掉,如下
/* It is very rare that the developer ever has full control of stdin,
so any use of gets warrants an unconditional warning. Assume it is
always declared, since it is required by C89.
#undef gets
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); */
再添加如下内容:
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
配置:
./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/m4_1.4.16/
make && make install
配置系统环境变量:
修改 .bashrc 文件
export PATH=/home/devilmaycry/anaconda3/mindspore_envs/m4_1.4.16/bin:$PATH
说明: 其中,/home/devilmaycry/anaconda3/mindspore_envs/m4_1.4.16 路径为我们刚才编译源码配置的安装路径的地址。
下载gmp 6.1.2
源码包:
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz
解压到当前文件夹:
tar -xvf gmp-6.1.2.tar.xz
配置:
./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/ --enable-cxx
编译安装:
make && make install
配置系统环境变量: 修改 .bashrc 文件
# gmp
export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/share:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH
测试 gmp 是否安装并配置成功:(声明:测试部分内容源于:https://blog.csdn.net/just_h/article/details/82667787)
代码:
# test.cpp 文件
#include <gmpxx.h>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
mpz_t a,b,c;
mpz_init(a);
mpz_init(b);
mpz_init(c);
gmp_scanf("%Zd%Zd",a,b);
mpz_add(c,a,b);
gmp_printf("c= %Zd\n",c);
return 0;
}
编译:
g++ test.cpp -o test -lgmp
运行:
mpfr 的安装:
下载地址:
wget https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz
解压文件:
tar -zxvf mpfr-4.1.0.tar.gz
配置:
./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/
编译安装:
make && make install
配置文件: 添加内容到 .bashrc 文件中
# mpfr
export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/share:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH
测试安装及配置是否成功:
代码: #test.cpp
#include <stdio.h>
#include <mpfr.h>
int main (void)
{
printf ("MPFR library: %-12s\nMPFR header: %s (based on %d.%d.%d)\n",
mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
return 0;
}
编译及运行:
gcc test.cpp -o test -lmpfr
mpc 的安装:
下载:
wget https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz
解压:
tar -zxvf mpc-1.2.1.tar.gz
配置:
./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/
编译安装:
make && make install
修改 .bashrc 文件,添加内容:
# mpc
export LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/share:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:$CPLUS_INCLUDE_PATH
GCC的安装:
下载gcc 7.3.0版本安装包,执行以下命令:
wget http://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
执行tar -xzf gcc-7.3.0.tar.gz
解压源码包。
执行cd gcc-7.3.0
,进入到源码包目录。
配置环境:
./configure --prefix=/home/devilmaycry/anaconda3/mindspore_envs/gcc_7.3.0 --enable-bootstrap -enable-threads=posix --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/home/devilmaycry/anaconda3/mindspore_envs/gmp_6.1.2 --with-mpfr=/home/devilmaycry/anaconda3/mindspore_envs/mpfr_4.1.0 --with-mpc=/home/devilmaycry/anaconda3/mindspore_envs/mpc_1.2.1
编译安装:
make && make install
标签:class 字段 系统 ash inf csdn nbsp bootstra boot
原文地址:https://www.cnblogs.com/devilmaycry812839668/p/15046425.html