Linux环境下,源码编译安装详解(编译CMake3.15和gcc5.3.0为例)
一. 源码编译安装详解
崇川ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
(待补充)
二. 安装CMake 3.15
1. 查看操作系统版本
[root@MySQL80 local]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
2. 下载软件
下载地址: https://cmake.org/download/
软件位置:/software/cmake-3.15.0-rc1.tar.gz
3. 创建安装目录
mkdir /usr/local/cmake-3.15.0
4. 配置安装
(1)切换到软件目录,解压软件包
[root@mysql80 cmake-3.15.0]# cd /software/ [root@mysql80 software]# ls -l | grep cmake-3.15.0-rc1.tar.gz -rw-r--r--. 1 root root 9249478 Jun 10 08:32 cmake-3.15.0-rc1.tar.gz [root@mysql80 software]# tar -zxvf cmake-3.15.0-rc1.tar.gz
(2)配置
[root@mysql80 software]# cd cmake-3.15.0-rc1/ [root@mysql80 cmake-3.15.0-rc1]# ./configure --prefix=/usr/local/cmake-3.15.0
完成配置,提示如下:
-----------------------------------------------------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /software/cmake-3.15.0-rc1
---------------------------------------------
CMake has bootstrapped. Now run gmake.
-------------------------------------------------------------------------------------------------------
(3)编译
make
(4)安装
make install
(5)校验
[root@mysql80 bin]# type cmake cmake is /usr/local/bin/cmake [root@mysql80 bin]# cmake --version cmake version 3.15.0-rc1 CMake suite maintained and supported by Kitware (kitware.com/cmake).
二.安装gcc-5.3.0
编译安装gcc-5.3.0, 需要注意两点:
(1)gcc本身是编译工具,那编译gcc的工具是什么?所以需要事先通过yum或rpm安装好之前版本的gcc。
yum install gcc gcc-c++ -y
(2)相关依赖包: GMP4.3.2 MPFR2.4.2 MPC0.8.1 ,需要依次事先安装好。
gmp http://ftp.gnu.org/gnu/gmp/
mpfr http://ftp.gnu.org/gnu/mpfr/
mpc http://ftp.gnu.org/gnu/mpc/
1. 安装GMP4.3.2
[root@mysql80 software]# mkdir /usr/local/gmp-4.3.2 [root@mysql80 software]# cd /software [root@mysql80 software]# ls -l | grep gmp -rw-r--r--. 1 root root 1897483 Jun 10 09:37 gmp-4.3.2.tar.bz2 [root@mysql80 software]# tar -jxvf gmp-4.3.2.tar.bz2 [root@mysql80 software]# cd gmp-4.3.2/ [root@mysql80 gmp-4.3.2]# ./configure --prefix=/usr/local/gmp-4.3.2 [root@mysql80 gmp-4.3.2]# make [root@mysql80 gmp-4.3.2]# make install
2.
安装MPFR2.4.2
[root@mysql80 software]# mkdir /usr/local/mpfr-2.4.2 [root@mysql80 software]# cd /software [root@mysql80 software]# ls -l | grep mpfr -rw-r--r--. 1 root root 1077886 Jun 10 09:38 mpfr-2.4.2.tar.bz2 [root@mysql80 software]# tar -jxvf mpfr-2.4.2.tar.bz2 [root@mysql80 software]# cd mpfr-2.4.2/ [root@mysql80 mpfr-2.4.2]# ./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2 [root@mysql80 gmp-4.3.2]# make [root@mysql80 gmp-4.3.2]# make install
3. 安装MPC0.8.1
[root@mysql80 software]# mkdir /usr/local/mpc-0.8.1 [root@mysql80 software]# cd /software [root@mysql80 software]# ls -l | grep mpc-0.8.1.tar.gz -rw-r--r--. 1 root root 544950 Jun 10 09:38 mpc-0.8.1.tar.gz [root@mysql80 software]# tar -zxvf mpc-0.8.1.tar.gz [root@mysql80 software]# cd mpc-0.8.1 [root@mysql80 mpc-0.8.1]# ./configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 [root@mysql80 gmp-4.3.2]# make [root@mysql80 gmp-4.3.2]# make install
----------------------------------------------------------------------------------------------------------------------
4. 修改环境变量
vim etc/profile
添加如下行:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-5.3.0/lib:/usr/local/gcc-5.3.0/lib64
使之生效:
source etc/profile
5. 安装GCC5.3.0
[root@mysql80 software]# mkdir /usr/local/gcc-5.3.0 [root@mysql80 software]# cd /software [root@mysql80 software]# ls -l gcc-5.3.0.tar.gz -rw-r--r--. 1 root root 123036849 Jun 10 09:17 gcc-5.3.0.tar.gz [root@mysql80 software]# tar -zxvf gcc-5.3.0.tar.gz [root@mysql80 software]# cd gcc-5.3.0/ [root@mysql80 gcc-5.3.0]# ./configure --prefix=/usr/local/gcc-5.3.0 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 [root@mysql80 gmp-4.3.2]# make -j4 [root@mysql80 gmp-4.3.2]# make install
6. 创建软连接
cd /usr/bin rm gcc rm g++ ln -s /usr/local/gcc-5.3.0/bin/g++ g++ ln -s /usr/local/gcc-5.3.0/bin/gcc gcc
7.校验
[root@mysql80 bin]# gcc --version gcc (GCC) 5.3.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE [root@mysql80 bin]# g++ --version g++ (GCC) 5.3.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
网站栏目:Linux环境下,源码编译安装详解(编译CMake3.15和gcc5.3.0为例)
分享路径:http://hbruida.cn/article/ieiihd.html