See all Redhat/CentOS/Fedora Core related FAQ
I have a Red Hat Enterprise Linux version 5 installed on one of the production server. However, I noticed that there is no GNU c/c++ compiler installed on the RHEL 5/RHEL 6 based system. I need to compile a few applications on this box. How do I install C or C++ compiler on Red Hat Enterprise Linux 5/6? Where can I get / download compiler package?

In order to compile and use c/c++ under RHEL you need the following packages:
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements RHEL5/CentOS5
Est. reading time 2 minutes
=> autoconf : GNU’s Autoconf is a tool for configuring source code and Makefiles.
=> make/automake : A GNU tool for controlling the generation of executables and other non-source files of a program from the program’s source files.

=> GNU GCC C compiler (gcc) : The gcc package contains the GNU Compiler Collection version 4.1+

=> GNU GCC C++ compiler (gcc-c++): This package adds C++ support to the GNU Compiler Collection.

You have total 3 options to download and install GCC compiler under Redhat / CentOS / Fedora Linux:

  • Use GUI tool to install compiler set
  • Install compiler rpms from CDROM/DVD
  • Download and install compiler from RHN over the Internet

Option # 1: Use GUI tool to install c/c++ compiler set

You can use a GUI tool called system-config-packages to install gcc. Just type the following command and select gcc and above packages:
$ system-config-packages &

Option # 2: Install rpm from CDROM/DVD

Mount your RHEL/CentOS Linux CD/DVD and install the following packages using rpm command:
# rpm -ivh gcc*

Option # 3: Download and install compiler from RHN over the Internet

You can download and install packages using RHN and yum command:
# yum install gcc gcc-c++ autoconf automake

This entry is 4 of 13 in the Linux GNU/GCC Compilers Tutorial series. Keep reading the rest of the series:
  1. Ubuntu Linux Install GNU GCC Compiler and Development Environment
  2. Debian Linux Install GNU GCC Compiler and Development Environment
  3. CentOS / RHEL 7: Install GCC (C and C++ Compiler) and Development Tools
  4. Download and Install C, C++ Compiler on Red Hat Enterprise Linux 5 (RHEL)
  5. Mac OS X: Install GCC Compiler with Xcode
  6. Where is My Linux GNU C or GCC Compilers Are Installed?
  7. HowTo: Compile And Run a C/C++ Code In Linux
  8. RHEL / CentOS Linux Install Core Development Tools Automake, Gcc (C/C++), Perl, Python & Debuggers
  9. HowTo Compiling C Program And Creating Executable File Under a Linux / UNIX / *BSD
  10. How To Install ncurses Library on a Linux
  11. Linux Find Out What Compilers Are Installed or Available On The System
  12. Linux Find Out GNU gcc Compiler Version Used To Compile Running Kernel
  13. Howto see output of C program in Linux or UNIX

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

83 comments… add one
  • amol Aug 25, 2015 @ 16:20

    plz detail information in linux using cpp

  • eaglesland Dec 18, 2015 @ 10:07

    Great post.
    I would add, that if you have any troubles with finding CD/DVD installation disc of RHEL, you can downloaded it from vault-centos. There you can find all the rmp needed for gcc installation (as well as their dependencies).

  • Shrey Feb 8, 2016 @ 17:45

    Thanks a lot .!

  • Ranushka Lakmal Jun 27, 2016 @ 18:31

    sudo dnf install gcc-c++

    {Try this}

  • Ranushka Lakmal Jun 27, 2016 @ 18:33

    [liveuser@localhost ~]$ sudo dnf install gcc-c++

    We trust you have received the usual lecture from the local System
    Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.