欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Is gcc is part of standard RHEL installation?

程序员文章站 2022-05-29 11:54:07
...

https://access.redhat.com/solutions/22999

Is gcc is part of standard RHEL installation?

 SOLUTION 已验证 - 已更新 2018年四月2日10:48 - 

English 

环境

  • Red Hat Enterprise Linux

问题

  • Is gcc is part of standard RHEL installation?
  • How to install compilers gcc and test if it is working?

决议

gcc is definitely available in the RHEL channels. However, whether or not it is installed would depend on the packages selected for the installation. Use yum to install gcc:

Raw

# yum install gcc

And if you would like to install development tools such as autoconf, automake, flex, c++ compiler, etc:

Raw

# yum grouplist

Raw

Available Groups:
   Backup Client
   Backup Server
   Client management tools
   Compatibility libraries
   Desktop Debugging and Performance Tools
   Desktop Platform Development
   Development tools  <-----------------------------------------------
   Eclipse
   Emacs
   FCoE Storage Client

Done

If you would like to know what are the basic components in this group packages:

Raw

# yum groupinfo "Development tools"

Raw

Group: Development tools
 Description: A basic development environment.
 Mandatory Packages:
   autoconf
   automake
   binutils
   bison
   flex
   gcc
   gcc-c++
   gettext
   libtool
   make
   patch
   pkgconfig
   redhat-rpm-config
   rpm-build

Raw

# yum groupinstall "Development Tools" 

诊断步骤

How to verify your gcc installation:

Raw

$ whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

How to see gcc compiler version:

Raw

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 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.

Let's create a little program to test if gcc is working:

Raw

$ vi redhat.c

Raw

#include<stdio.h>
int main(void){
    printf("Hello Red Hat!\n");
    return 0;
}

Now, let's compile to generate an executable file:

Raw

$ gcc redhat.c -o redhat

Execute the program:

Raw

$ ./redhat
Hello Red Hat!
相关标签: gcc