CentOS/RHEL 7:安装GCC(C和C ++编译器)和开发工具
时间:2020-01-09 10:34:15 来源:igfitidea点击:
如何在CentOS 7或Red Hat Enterprise Linux版本7服务器上安装gnu gcc编译器和相关工具,例如autoconf,automake,flex,c ++编译器和bison?
如何在CentOS或RHEL 7上安装GCC(C和C ++编译器)和开发工具?
您可以在CentOS Enterprise Linux或Red Hat Enterprise Linux版本7上使用以下软件包设置基本的开发环境:
CentOS/RHEL 7:安装GCC软件包列表
- autoconf
- automake
- binutils
- bison
- flex
- gcc (c compiler)
- gcc-c++ (c++ compiler)
- gettext
- libtool
- make
- patch
- pkgconfig
- redhat-rpm-config
- rpm-build
- rpm-sign
安装GCC C和C ++
打开终端应用程序,然后键入以下命令。
在CentOS/RHEL 7上列出组的命令
键入以下yum命令:
# yum group list
输出示例:
CentOS/RHEL 7:列表软件包组命令
另外一个选项:
# yum group list ids
输出示例:
Loaded plugins: fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: mirror01.idc.hinet.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net Available Environment Groups: Minimal Install (minimal) Compute Node (compute-node-environment) Infrastructure Server (infrastructure-server-environment) File and Print Server (file-print-server-environment) MATE Desktop (mate-desktop-environment) Basic Web Server (web-server-environment) Virtualization Host (virtualization-host-environment) Server with GUI (graphical-server-environment) GNOME Desktop (gnome-desktop-environment) KDE Plasma Workspaces (kde-desktop-environment) Development and Creative Workstation (developer-workstation-environment) Available Groups: CIFS file server (cifs-file-server) Compatibility Libraries (compat-libraries) Console Internet Tools (console-internet) Desktop (basic-desktop) Desktop Platform (desktop-platform) Desktop Platform Development (desktop-platform-devel) Development Tools (development) Eclipse (eclipse) Educational Software (education) Electronic Lab (electronic-lab) FCoE Storage Client (storage-client-fcoe) Fedora Packager (fedora-packager) General Purpose Desktop (general-desktop) Graphical Administration Tools (graphical-admin-tools) Haskell (haskell) Legacy UNIX Compatibility (legacy-unix) Messaging Client Support (system-management-messaging-client) Messaging Server Support (system-management-messaging-server) Milkymist (milkymist) MySQL Database client (mysql-client) MySQL Database server (mysql) NFS file server (nfs-file-server) Network Storage Server (storage-server) SNMP Support (system-management-snmp) Scientific Support (scientific) Security Tools (security-tools) Server Platform (server-platform) Server Platform Development (server-platform-devel) Smart Card Support (smart-card) Storage Availability Tools (storage-client-multipath) System Administration Tools (system-admin-tools) System Management (system-management) TeX support (tex) TurboGears application framework (turbogears) Virtualization (virtualization) Web-Based Enterprise Management (system-management-wbem) Xfce (xfce-desktop) iSCSI Storage Client (storage-client-iscsi) Done
在CentOS/RHEL 7服务器上安装GCC和开发工具的命令
以超级用户身份键入以下yum命令:
# yum group install "Development Tools"
或者
$ sudo yum group install "Development Tools"
如果以上命令失败,请尝试:
# yum groupinstall "Development Tools"
输出示例:gif动画01:在CentOS和RHEL 7上安装C&C ++和相关软件包
关于在CentOS/RHEL 7.x上的组安装失败的说明
要安装属于称为"开发工具"的软件包组的所有软件包,请使用以下命令:
# yum --setopt=group_package_types=mandatory,default,optional groupinstall "Development Tools"
或者
# yum --setopt=group_package_types=mandatory,default,optional group install "Development Tools"
在Red Hat Enterprise Linux 7/CentOS 7中更改了yum。
软件包组Development Tools仅包含可选软件包,默认情况下不会安装这些可选软件包。
因此,我们将需要传递选项--setopt = group_package_types = mandatory,default,optional
来安装可选软件包。
验证您在CentOS/RHEL 7服务器上的gcc安装
键入以下命令以查看gcc位置:
$ whereis gcc gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz
键入以下命令以查看gcc编译器版本:
$ gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16) Copyright (C) 2013 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.
使用foo.c程序测试gcc C编译器示例
创建一个名为foo.c的文件,如下所示:
#include<stdio.h> int main(void){ printf("Hello World!\n"); return 0; }
要将foo.c编译为foo可执行文件,请输入:
$ cc foo.c -o foo
要执行foo程序,请输入:
$ ./foo Hello World!
关于在CentOS 6/7上安装手册页的说明
使用yum命令,如下所示:
$ ## [ CentOS 7 ] ## $ sudo yum install man-pages man-db man $ ## [ CentOS 6.x ] ## $ sudo yum install man man-pages