• linux 安装gcc8


    https://blog.csdn.net/longji/article/details/80400339

    01 ubuntu1604desktop_x64 安装gcc8.1.0
    系统环境:

    gcc版本:gcc version 5.4.0 20160609
    build-essential is already the newest version (12.1ubuntu2).
    libgmp-dev is already the newest version (2:6.1.0+dfsg-2).
    libmpc-dev is already the newest version (1.0.3-1).
    libmpfr-dev is already the newest version (3.1.4-1).
    The following packages were automatically installed and are no longer required:
    libqpdf17 linux-headers-4.4.0-79 linux-headers-4.4.0-79-generic
    linux-image-4.4.0-79-generic linux-image-extra-4.4.0-79-generic
    1
    2
    3
    4
    5
    6
    7
    8
    01.01 系统更新及安装依赖
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install build-essential libgmp-dev libmpfr-dev libmpc-dev
    1
    2
    3
    01.02 gcc代码下载及编译
    wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-8.1.0/gcc-8.1.0.tar.xz
    tar -Jxvf gcc-8.1.0.tar.xz
    cd gcc-8.1.0
    ./contrib/download_prerequisites
    cd ..
    mkdir temp_gcc81 && cd temp_gcc81
    ../gcc-8.1.0/configure --prefix=/usr/local/gcc-8.1 --enable-threads=posix --disable-checking --disable-multilib
    make
    sudo make install
    1
    2
    3
    4
    5
    6
    7
    8
    9
    01.03 环境配置
    设置gcc8.1的安装路径
    sudo vim /etc/profile

    export PATH="/usr/local/gcc-8.1/bin:$PATH"
    1
    01.04 测试
    测试文件test_gcc81.cpp

    #include <iostream>
    int main(int argc,char** argv)
    {
    using namespace std;
    cout << __cplusplus << endl;
    return 0;
    }
    1
    2
    3
    4
    5
    6
    7
    01.05 c++2a
    编译 g++ --std=c++2a -o tg81 test_gcc81.cpp
    运行结果:

    ./tg81
    201709
    1
    2


    01.06 gcc7.2
    gcc7.2 在ubuntu1604_x64下的编译方式完全相同。
    测试效果:

    $ g++ --std=c++2a -o tg72 test_gcc81.cpp
    g++: error: unrecognized command line option ‘--std=c++2a’; did you mean ‘--std=c++03’?
    $ g++ --std=c++14 -o tg72 test_gcc81.cpp
    $ ./tg72
    201402
    1
    2
    3
    4
    5
    02 centos7.4x64 上编译安装gcc8.1.0
    02.01 系统环境以安装依赖
    #默认gcc版本
    gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)

    # 更新系统
    sudo yum update
    sudo yum upgrade

    # 安装gcc编译依赖
    sudo yum install gmp-devel mpfr-devel libmpc-devel
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    * base: mirrors.cn99.com
    * extras: mirrors.aliyun.com
    * updates: mirrors.aliyun.com
    Package 1:gmp-devel-6.0.0-15.el7.x86_64 already installed and latest version
    Package mpfr-devel-3.1.1-4.el7.x86_64 already installed and latest version
    Package libmpc-devel-1.0.1-3.el7.x86_64 already installed and latest version
    1
    2
    3
    4
    5
    6
    7
    8
    02.03 下载源码及编译安装
    wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-8.1.0/gcc-8.1.0.tar.xz
    tar -Jxvf gcc-8.1.0.tar.xz
    mkdir temp_gcc81 && cd temp_gcc81
    ../gcc-8.1.0/configure --prefix=/usr/local/gcc-8.1 --enable-threads=posix --disable-checking --disable-multilib
    make
    sudo make install
    1
    2
    3
    4
    5
    6
    02.03 测试效果:
    $cat test_gcc81.cpp
    #include <iostream>
    int main(int argc,char** argv)
    {
    using namespace std;
    cout << __cplusplus << endl;
    return 0;
    }

    $g++ --std=c++2a -o tg81 test_gcc81.cpp
    $./tg81
    201709
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    ---------------------
    作者:longji
    来源:CSDN
    原文:https://blog.csdn.net/longji/article/details/80400339
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    tp5 自定义配置文件
    php 连接redis
    Redis Desktop manager连接redis
    支付宝面对面扫码支付教程
    java.lang.IllegalAccessError: org.apache.commons.dbcp.DelegatingPreparedStatement.isClosed()
    Windows环境下用Myeclipse创建Maven项目Jsp页面报错的问题
    maven项目中配置自定义welcome-file
    Bootstrap实现图片轮播
    Java中的final 修饰参数问题
    Java迭代器Iterator理解
  • 原文地址:https://www.cnblogs.com/jasonxiaoqinde/p/10531372.html
Copyright © 2020-2023  润新知