Manjaro in the source installation gcc7.1

Source: Internet
Author: User
Tags gmp

Just GCC 7.1 also came out, want to use the familiar Linux under test, special record as follows:

Prepare the necessary system environment: (Upgrade the system to the latest, install the necessary tools)

Pacman-syyu #升级系统到最新
Pacman-q GCC gawk M4 binutils lzip #查看必备工具是否具备, no on installation, my missing lzip, after installation, results

GCC 6.3.1-2
Gawk 4.1.4-2
M4 1.4.18-1
Binutils 2.28.0-2
Lzip 1.19-1

mkdir gcc_builder_7.1 && CD gcc_builder_7.1

# download three required libraries GMP, MPFR, MPC; Depending on the dependency: MPFR relies on GMP and the MPC relies on GMP and MPFR. Download order does not matter, the order must be installed first install GMP, then install MPFR, and then install the MPC, finally install GCC, because the files are interdependent, do not mistake order.

#获取必要的文件
# GMP
wget Https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz
# MPFR
wget HTTP://WWW.MPFR.ORG/MPFR-CURRENT/MPFR-3.1.5.TAR.XZ
# MPC
wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
# gcc-7.1
wget http://mirrors.webhostinggeeks.com/gcc/releases/gcc-7.1/gcc-7.1.tar.bz2

#新建源码解压保存目录,use the corresponding tool to extract to the corresponding directory, it is best not to have a version number:
# Decompression of GMP
Lzip-d Gmp-6.1.2.tar.lz
TAR-XVF Gmp-6.1.2.tar && MV gmp-6.1.2 GMP
# Unzip MPFR
TAR-JXVF mpfr-3.1.5.tar.xz && MV mpfr-3.1.5 MPFR
# decompression MPC
TAR-ZXVF mpc-1.0.3.tar.gz && MV mpc-1.0.3 MPC
# Unzip GCC
TAR-JXVF gcc-7.1.tar.bz2 && mv gcc-7.1 GCC

# Compile GMP library, install to/usr/gcc_7_1 directory to X86_64-linux-gnu kernel
CD GMP #进入gmp源码目录
mkdir build && CD Build #准备编译目录
.. /configure--prefix=/usr/gcc_7_1--build=x86_64-linux-gnu #配置编译选项
Make-j4 #编译
sudo make install #编译安装

# Compile MPFR library, install to/usr/gcc_7_1 directory to X86_64-LINUX-GNU kernel to GMP library
Cd.. /.. /MPFR #进入mpfr源码目录
mkdir build && CD Build #准备编译目录
.. /configure--build=x86_64-linux-gnu--prefix=/usr/gcc_7_1--with-gmp=/usr/gcc_7_1 #配置编译选项
Make-j4#编译
sudo make install #编译安装

# Compile MPC library, rely on GMP, MPFR, kernel ...
Cd.. /.. /MPC #进入mpc源码目录
mkdir build && CD Build #准备编译目录
.. /configure--build=x86_64-linux-gnu--prefix=/usr/gcc_7_1--with-gmp=/usr/gcc_7_1--with-mpfr=/usr/gcc_7_1 #配置编译选项
Make-j4#编译
sudo make install #编译安装

#编译GCC源码
Cd.. /.. /#进入gcc源码目录
mkdir build && CD Build #准备编译目录
Export library_path=/usr/lib/x86_64-linux-gnu/
Export C_INCLUDE_PATH=/USR/INCLUDE/X86_64-LINUX-GNU
Export CPLUS_INCLUDE_PATH=/USR/INCLUDE/X86_64-LINUX-GNU
#下一行是配置编译环境
.. /gcc/configure--build=x86_64-linux-gnu--prefix=/usr/gcc_7_1--with-gmp=/usr/gcc_7_1--with-mpfr=/usr/gcc_7_1-- With-mpc=/usr/gcc_7_1--enable-checking=release--enable-languages=c,c++,fortran--disable-multilib-- program-suffix=-7.1
Make-j4#编译

#make-jn, you can adjust the value of N, for example: Make-j4, if the compilation error, execute make clean after making, only the compilation process will be slow.
sudo ln-s/usr/lib/x86_64-linux-gnu//usr/lib64 #链接库文件
sudo make install #编译安装
Export Path=/usr/gcc_7_1/bin: $PATH

#将gcc 7.1 Add to the system path, or edit the home directory directly under the. bashrc file, and then add the export path=/usr/gcc_7_1/bin: $PATH

# Invoke Compiler Test
Gcc-7.1-v #结果如下:
Use built-in specs.
collect_gcc=gcc-7.1
Collect_lto_wrapper=/usr/gcc_7_1/libexec/gcc/x86_64-linux-gnu/7.1.0/lto-wrapper
Target: X86_64-linux-gnu
Configured as:.. /gcc/configure--build=x86_64-linux-gnu--prefix=/usr/gcc_7_1--with-gmp=/usr/gcc_7_1--with-mpfr=/usr/gcc_7_1-- With-mpc=/usr/gcc_7_1--enable-checking=release--enable-languages=c,c++,fortran--disable-multilib-- program-suffix=-7.1
Threading Model: POSIX
GCC version 7.1.0 (GCC)

#就表明安装成功

Manjaro in the source installation gcc7.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.