本文介绍在RHEL 8/CentOS 8系统上安装GCC和Development Tools(开发工具)的方法。如果要在RHEL/CentOS 8上进行开发或构建开源应用程序,则需要安装包含的Development tools有:autoconf、automake、gcc、gcc-c++、bison、flex、binutils、gdb、glibc-devel、libtool、make、pkgconf、pkgconf-m4、pkgconf–pkg-config、redhat-rpm-config、rpm-build、rpm-sign、strace。
列出CentOS/RHEL 8上的软件包组 输入以下dnf命令以列出CentOS/RHEL 8上可用的软件包组: $ dnf group list Updating Subscription Management repositories. Updating Subscription Management repositories. Last metadata expiration check: 0:02:38 ago on Sun 17 Mar 2019 09:28:36 AM EAT. Available Environment Groups: Minimal Install Workstation Custom Operating System Installed Environment Groups: Server Installed Groups: Container Management Development Tools Available Groups: .NET Core Development RPM Development Tools Smart Card Support Scientific Support Security Tools System Tools Headless Management Network Servers Legacy UNIX Compatibility Graphical Administration Tools 你可以加上相关选项以查看已安装组、可用组、可用环境组以及已安装和可用语言组的数量: $ sudo dnf groups summary Updating Subscription Management repositories. Updating Subscription Management repositories. Last metadata expiration check: 0:06:33 ago on Sun 17 Mar 2019 09:28:36 AM EAT. Installed Groups: 2 Available Groups: 10
在CentOS/RHEL 8上安装GCC和Development Tools(开发工具) 以下命令用于在CentOS/RHEL 8系统上安装GCC和Development Tools(开发工具): sudo dnf group install "Development Tools" 或者: sudo dnf groupinstall "Development Tools" 你可以在Development Tools包组中查看信息: sudo dnf group info "Development Tools" 通过检查工具二进制位置验证安装: $ whereis bison gcc flex bison: /usr/bin/bison /usr/share/bison /usr/share/man/man1/bison.1.gz /usr/share/info/bison.info.gz gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz /usr/share/info/gcc.info.gz flex: /usr/bin/flex /usr/share/man/man1/flex.1.gz /usr/share/info/flex.info-1.gz /usr/share/info/flex.info-2.gz /usr/share/info/flex.info.gz 检查已经安装的GCC版本: $ gcc --version gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3) Copyright (C) 2018 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. $ make --version GNU Make 4.2.1 Built for x86_64-redhat-linux-gnu Copyright (C) 1988-2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. GCC 8.2更新说明:GCC 8.2发布下载,解决了最高优先级性能回退问题。
在CentOS/RHEL 8上卸载GCC和Development Tools(开发工具) 以下是用于删除CentOS/RHEL 8上的软件包组的命令: sudo dnf group remove "Development Tools"
测试GCC编译器 让我们创建一个Hello World程序,看看它是否能正确编译: $ cat hello.c #include <stdio.h> int main() { printf("Hello, world!\n"); return 0; } 用GCC编译代码: gcc hello.c -o helloworld 运行程序,看它是否打印Hello, world!: $ ./helloworld Hello, world! 至此,能正常编译。
相关主题 |