• Linux下clang、gcc、intel编译器最新版本安装笔记


    系统平台:Red-Hat-Enterprise-Linux-Server-6.0-X86_64

    1、clang-3.2安装笔记

    (1)下载clang、llvm、compiler-rt源代码

        LLVM-3.2源代码下载: LLVM source code(12M)

        clang-3.2源代码下载:Clang source code(8.4M)

        compiler-rt源代码下载:Compiler RT source code(1.4M)

    clang-3.2.src.tar.gz
    compiler-rt-3.2.src.tar.gz llvm-3.2.src.tar.gz

     (2)解压下载的源代码压缩包

    tar -zxf llvm-3.2.src.tar.gzs  # 解压后文件夹名为llvm-3.2.src,将其重命名为llvm-3.2
    tar -zxf clang-3.2.src.tar.gz  # 解压后文件夹名为clang-3.2.src,将其重命名为clang并将其移动到llvm-3.2/tools目录之下
    tar -zxf compiler-rt-3.2.src.tar.gz # 解压后文件夹名为compiler-rt-3.2.src,将其重命名为compiler-rt-3.2并将其移动到llvm-3.2/projects目录之下

        然后在于llvm-3.2所在目录新建一个build目录,这样最终得到的目录结构关系如下所示:

    ├── build
    └── llvm-3.2
        ├── projects
        │   └── compiler-rt
        └── tools
            └── clang

        【说明】:我们将在build目录中进行构建llvm、clang和compiler-rt,之所以这样是为了让源代码保持干净,生成的目标文件都在这里。另外将clang和compiler-rt目录分别放入llvm-3.2相应的子目录下是为了在构建llvm的同时,自动构建clang和compiler-rt。

    (3)构建llvm、clang和compiler-rt

    cd build
    ../llvm-3.2/configure
    make

    (4)设置环境变量

        上述第(3)步成功后,clang已经成功编译到了build/Release+Asserts/bin目录之中,至此只需将clang所在目录添加到PATH环境变量中,clang就可以使用了。

        【说明】:前些日子也记录过一篇关于编译clang的文章(http://www.cnblogs.com/soaliap/archive/2012/07/23/2605278.html),当时是从主干直接下载代码的,编译的为Debug版本,很浪费硬盘空间(超过7G),这里下载并编译的为Release版本,就小的多了(不到1G)。

    2、gcc-4.7.2安装笔记

    (1)、gcc-4.7.2源码下载

        打开http://www.gnu.org/software/gcc/gcc-4.7/页面,左下角可以看到下载镜像站点和SVN服务器地址,本人是从FTP镜像站点下的,并且是.tar.bz2格式(这个格式压缩比较好,压缩文件较小)。

    (2)、解压压缩包

        tar -jxf gcc-4.7.2.tar.bz2

    (3)、初次尝试

        解压后文件夹为gcc-4.7.2,同上面构建clang一样,新建与gcc-4.7.2同级的目录build,并进入其中执行:

        ../gcc-4.7.2/configure --prefix=/opt/gcc/4.7.2

        不幸的是报错了,错误信息如下:

    ......
    checking for the correct version of gmp.h... no
    configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
    Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
    their locations.  Source code for these libraries can be found at
    their respective hosting sites as well as at
    ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
    http://gcc.gnu.org/install/prerequisites.html for additional info.  If
    you obtained GMP, MPFR and/or MPC from a vendor distribution package,
    make sure that you have installed both the libraries and the header
    files.  They may be located in separate packages.

         从错误信息中可以看出,需要安装gmp、mpfr和mpc,如果已经安装了,并且安装在了非系统默认能够查找到的位置,则需要通过--with-gmp、--with-mpfr、--with-mpc三个选项指定安装位置。

    (4)、安装gmp、mpfr和mpc

        gmp可以从http://gmplib.org/下载,解压后执行:

    ./configure --prefix=/usr/local/gmp-5.1.0
    make
    make install

        mpfr可以从http://www.mpfr.org/下载,解压后执行:

    ./configure --prefix=/usr/local/mpfr-3.1.1 --with-gmp=/usr/local/gmp-5.1.0
    make
    make install

        mpc可以从http://www.multiprecision.org/下载,解压后执行:

    ./configure --prefix=/usr/local/mpc-1.0.1 --with-mpfr=/usr/local/mpfr-3.1.1 --with-gmp=/usr/local/gmp-5.1.0
    make
    make install

        设置环境变量:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-5.1.0/lib:/usr/local/mpfr-3.1.1/lib:/usr/local/mpc-1.0.1/lib

         【说明】:由于上述三个库的依赖关系为:mpc依赖于mpfr和gmp,mpfr依赖于gmp,因此这三个库的安装先后顺序必须为:gmp、mpfr、mpc。另外,值得一提的是本人一开始想偷懒,不指定gmp、mpfr、mpc的安装目录,让它们安装到默认的路径,这样就可以不设置环境变量,也不需使用--with-gmp、--withmpfr、--with-mpc三个选项了,可没想到重新make的时候(编译gcc的时候)会报错:“configure: error: cannot compute suffix of object files: cannot compile”,于是只好老老实实按照上述步骤再做一遍。

    (5)、重新构建

    ../gcc-4.7.2/configure --prefix=/opt/gcc/4.7.2 --with-mpc=/usr/local/mpc-1.0.1 --with-mpfr=/usr/local/mpfr-3.1.1 --with-gmp=/usr/local/gmp-5.1.0
    make

        make的时候还有错误:“/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory”,解决方法是在执行configure时加上--disable-multilib选项。

     (6)、再次重新构建

    ../gcc-4.7.2/configure --prefix=/opt/gcc/4.7.2 --with-mpc=/usr/local/mpc-1.0.1 --with-mpfr=/usr/local/mpfr-3.1.1 --with-gmp=/usr/local/gmp-5.1.0 --disable-multilib
    make
    make install

     (7)、设置环境变量

    export PATH=/opt/gcc/4.7.2/bin:$PATH
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gcc/4.7.2/lib64:/usr/local/gmp-5.1.0/lib:/usr/local/mpfr-3.1.1/lib:/usr/local/mpc-1.0.1/lib

        至此,g++-4.7.2已经可以正常使用了。

        【说明】:若是安装过程还有别的问题,可以瞅瞅这篇文章,http://blog.csdn.net/gengshenghong/article/details/7498085,看能否找到答案。

     3、Intel C++编译器安装笔记

    (1)、申请评估版本

        intel编译器并不开放源代码,但是提供一个30天免费使用的评估版本,需要到intel官方网站申请(http://software.intel.com/en-us/intel-software-evaluation-center)填写申请信息提交后,会收到intel发给你的一封邮件,其中有下载的链接。

        说明】:默认下载的版本能够安装在32位系统或64位系统之中,但是下载的压缩包比较大(1.5G),如果你只想要安装在64位系统上,那么下载intel64版本的即可(仅有968M),另外也有32位版本。

    (2)、安装

        下载完成后,解压,里面有个shell脚本(install.sh),运行它即可。安装过程更装windows程序没什么两样,只不过是命令行形式的,需要你手动敲accept和安装选项而已。

    (3)、设置环境变量

        intel提供了shell脚本来帮助你简化环境变量设置,只需执行:

    source /opt/intel/bin/compilervars.sh intel64     # /opt/intel为安装目录
  • 相关阅读:
    ant design vue模态框中下拉滚动样式分离解决方法
    vue+element处理前端分页
    vue中引入图片报Error: Can't resolve '../../assets/xx.png' in 'xxxx' 无法解析错误记录
    同页面多个echarts饼图组件封装
    后台报错"Optional int parameter 'page' is present but cannot be translated into a null value due to being declared as a primitive type"
    ant design vue中table动态合并列
    vuex数据持久化
    ant design vue中使用TreeSelect懒加载
    vue报错You are using the runtime-only build of Vue where the template compiler
    ant design vue中表格自带分页
  • 原文地址:https://www.cnblogs.com/opangle/p/2838554.html
Copyright © 2020-2023  润新知