首页 > 系统相关 >centos7 编译gcc

centos7 编译gcc

时间:2024-05-13 22:52:29浏览次数:27  
标签:gcc CentOS source GCC centos7 编译 version install

https://linuxhostsupport.com/blog/how-to-install-gcc-on-centos-7/

 

How To Install GCC on CentOS 7

rial, we will take a look at how to install GCC on CentOS 7. GCC or GNU Compiler Collection is released by the Free Software Foundation and as the name suggests, it is a very useful collection of programming compilers such as C, C++, Objective-C, Objective-C++, Fortran, Java, Go and Ada. GCC is an official compiler of the GNU operating system but also it is a standard compiler on many Unix operating systems such as Linux. Installing GCC on CentOS 7, is really an easy task and it shouldn’t take more than 10 minutes.

 

1. Update the server

First of all log in to your CentOS 7 VPS via SSH as user root

ssh root@IP_Address -p Port_number

and make sure that all installed packages on the server are up to date

yum -y update

2. Install GCC from repository

GCC can be easily installed from the official CentOS repositories. Run the following command to install GCC on your server

yum -y install gcc

Once the installation is completed, you can the version of GCC installed on your server

gcc --version

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
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.

As might be seen from the output, the GCC version distributed by CentOS 7 is 4.8.5 which is not the latest version of GCC.

You may also want to install gcc-c++. It will automatically include the C++ library and compile files with extensions that indicate they are C source as C++, instead of as C.

yum -y install gcc-c++

3. Install GCC from source

If you need a newer version of GCC than the one distributed by the official CentOS 7 repositories you can install it from source.

It is highly recommended to start a screen session before starting the installation. Run the following command

screen -U -S gcc

Download the tarball of the GCC version you want to install. In our example we will use GCC version 7.3.0

wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-7.3.0/gcc-7.3.0.tar.gz

Unpack the tar archive and change the current working directory

tar zxf gcc-7.3.0.tar.gz
cd gcc-7.3.0

Install bzip2 and run the ‘download_prerequisites’ script to download some prerequisites needed by GCC. You have to run this from the top level of the GCC source tree.

yum -y install bzip2
./contrib/download_prerequisites

Once the prerequisites are downloaded execute the following command to start configuring the GCC build environment

./configure --disable-multilib --enable-languages=c,c++

Once it is completed, run the following command to compile the source code. It may take a few hours for the compilation to complete, so sit back and relax.

make -j 4
make install

4. Verify GCC installation on CentOS 7

After the compilation process is completed. You can check if GCC is properly installed.

gcc --version

gcc (GCC) 7.3.0
Copyright (C) 2017 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.

标签:gcc,CentOS,source,GCC,centos7,编译,version,install
From: https://www.cnblogs.com/wolbo/p/18190244

相关文章

  • MAC make编译报错 “clang: error: unsupported option '-fopenmp'”
    编译报错➜php_mt_seed-mainmakegcc-Wall-march=native-mtune=generic-O2-fomit-frame-pointer-funroll-loops-fopenmpphp_mt_seed.c-ophp_mt_seedclang:error:unsupportedoption'-fopenmp'clang:error:unsupportedoption'-fopenmp'......
  • CentOS7部署Docker(联网)
    一、参考地址https://blog.csdn.net/m0_49762804/article/details/131398587二、Docker安装安装依赖环境,yum-utils##检查是否安装[root@localhostES]#dockerps[root@localhostES]#yum-yinstallyum-utilsdevice-mapper-persistent-datalvm2备注:使用yum工具下......
  • CentOS7部署ES(单机)
    一、创建路径,解压##创建路径[root@localhost/]#cd/data[root@localhostdata]#mkdirES##解压[root@localhostdata]#cdES[root@localhostES]#lselasticsearch-8.11.3-linux-x86_64.tar.gz[root@localhostES]#tar-zxvfelasticsearch-8.11.3-linux-x86_64.ta......
  • 【运维系列】-- Centos7 防火墙
    一、介绍在centos7中,有几种防火墙共存:firewald,iptables.默认情况下,CentOS是使用firewalld来管理netfilter子系统,不过底层调用的命令仍然是iptables二、firewalld和iptables区别firewalld可以动态修改单挑规则,而不像iptables那样,在修改了规则后必须全部刷新才可以生效......
  • 编译原理和计算机系统结构复习随笔
    (一)知识点补充阶段5.35.45.55.61、系统结构网课(1)1、编译网课(1)2、做出今天看的编译大题模板3、划出昨天看的系统结构知识点+尝试背诵系统结构书1、系统结构网课(2)2、做出今天看的系统结构大题模板3、划出今天看的系统结构知识点+尝试背诵系统结构书1、编译网课(......
  • CentOS7部署Redis(离线单机)
    一、检查是否安装##检查是否安装了Redis[root@localhost/]#ps-ef|grepredis##存在就删除[root@localhost/]#sudoyumremoveredis##检查是否安装了gcc[root@localhost/]#gcc--version安装gcc1、手动离线安装下载gcc安装包,下载地址:http://mirrors.ali......
  • CentOS7离线部署JDK
    一、 下载JDK官网地址:https://www.oracle.com/java/technologies/downloads/#java18二、安装部署点击查看代码##创建存放的文件夹[root@localhost/]#cd/[root@localhost/]#mkdirdata[root@localhost/]#cd/data[root@localhostdata]#mkdirjava##解压,安......
  • varnish源码编译以及简单配置
    varnish安装系统centos7ip192.168.40.131禁止透明大页echonever>/sys/kernel/mm/transparent_hugepage/enabled减少最大堆栈大小ulimit-s256安装nginxyumlist|grep^nginx&&yum-yinstallnginx*mkdir/usr/share/nginx/html/helloecho“hellowo......
  • 如何编译Godot(Godot & Godot with C#)
    要在Windows下编译Godot,需要以下环境:VisualStudioCommunity:使用最新版本。MinGW-w64:可以替代VisualStudio。请务必将其安装/配置为使用posix线程模型。使用MinGW编译主分支时,需要GCC9或更高版本。Python3.6+:确保在安装程序中启用将Python添加到环境变量......
  • 代码(CODE)到二进制(BIN)文件的编译过程
    这些步骤将源代码转换成可以在目标硬件上执行的机器代码。以下是这个过程的一般描述:预处理(Preprocessing):源代码(如.c、.cpp、.s等)首先被预处理。预处理器处理源文件中的宏定义、条件编译指令、包含指令(如#include)等。预处理器的输出通常是一个.i或.ii文件,它包含了所有宏替......