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 5m
=> 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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 83 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
83 comments… add one
  • ali110 Aug 5, 2007 @ 3:18

    i wont compiler c linux redhat as4

  • Rajic Aug 17, 2007 @ 14:12

    Its Great to use needed this kind of blogs

  • anas Sep 2, 2007 @ 5:42

    Very use full thanks lot

  • Rod Evans Nov 22, 2007 @ 16:47

    This really is one of the clearest and most helpful answers to a tech question that I’ve ever seen. I’ve just taken on a RHEL v5 server and needed gcc installed – ten minutes after finding this site, I have gcc 4.1.2 installed. This must have saved me a few hours of searching and reading install instructions . . .

    I found your site through Google but have now bookmarked it and I’ll be back!

  • ttty Dec 20, 2007 @ 7:46

    thanks for the info!

  • xfgs Mar 31, 2008 @ 11:27

    why registration is Required???? if it is free
    u will get hit more if u remove this step

  • zoya Aug 13, 2008 @ 12:37

    how would i install c language

  • karuppu Aug 23, 2008 @ 15:46

    thank u

  • Justin Jan 16, 2009 @ 1:48

    thanks for the info! It is very useful!

  • Nitin Feb 23, 2009 @ 7:18

    I have problem in installing *.tar.gz file on my machine…

  • Nitin Feb 23, 2009 @ 7:23

    replay must is very argent for me…

  • rafael ortega Mar 15, 2009 @ 2:27

    in reading your blog i’m as confused and lost as ethernet is to phone transmission; i installed mandriva free and that is the os i’m using at present; i then foolishly bought their powerpack, thinking it would solve the problems that mandriva one was presenting to me; having downloaded it and installed it due to my ignorance in handling this os i made it unusable; i then repeatedly tried to reinstall it only to find that the operating system will not load giving me an error message: fatal error message which i cannot overcome, yet.
    can you help?

  • rafael ortega Mar 15, 2009 @ 2:29

    is there anyone there who knows what i can do?

  • yadav shakti Jul 8, 2009 @ 19:40

    where i downloard and installation process

  • yadav shakti Jul 8, 2009 @ 19:41

    from i install the g++ software or c/c++

  • Raihan Naufal Aug 20, 2009 @ 6:27

    thanks a lot bro. this the good article.

  • vipin Aug 24, 2009 @ 18:43

    thanks for the info!

  • omar Aug 26, 2009 @ 15:10

    After typing the following command “$ which gcc” to verify that gcc is installed, the Output was “/usr/bin/which: no gcc in (/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/omar/bin)
    ” , instead of being “/usr/bin/gcc”. what i have to do now?

  • Sarin Eabenson Sep 7, 2009 @ 18:42

    i want to install cpp in my computer

  • kagrrahang Nov 6, 2009 @ 8:20

    where download the gcc rpm program package?

  • noname Dec 14, 2009 @ 17:23

    Keep in mind that developer packages (ie compiler tools) are not available for RHEL Desktop Basic, you need at least option Workstation.

  • velan Feb 21, 2010 @ 14:53

    thanks for the info! It is very useful!

  • sam Feb 25, 2010 @ 19:05

    i install gcc-c++ but how open the compiler i want compile a program then what should i do

  • Sriharsha May 12, 2010 @ 13:57

    Hi, I want to install c language as same like as in windows. How to install it?

  • kapil May 19, 2010 @ 10:37

    i want c/c++ or g++ complier for redhat linux.please send this packege in my mail ID.

  • Kiran May 27, 2010 @ 16:26

    I have installed c compiler using method 3 on fedora 11…….But still I can’t able to run C program….using gcc…..

    • Sriharsha May 28, 2010 @ 14:06

      Try to export all the header files and it will work. It worked for me.

  • FSFV Staff Jun 21, 2010 @ 7:20

    i will try it for my centos 5

  • Krishna Jul 7, 2010 @ 19:04

    Thanks for the help.

  • nisamudeen Jul 14, 2010 @ 4:56

    helpful link

  • reese Aug 13, 2010 @ 3:02


    I have a program consists of header files, .cpp, .c, a Makefile and need to include the problem instances file (.tim).

    May i know how to compile and run them? From google, i have heard bout the command make. But i have no idea how. Please kindly help..



  • narahari Aug 16, 2010 @ 8:26

    hi i brought new free pardus linux os,,, but it is not having GCC compiler..i want that…please help me. how to buy and install the compiler

    • vidya Apr 9, 2011 @ 16:51

      hi i have installed fedora in my laptop but when i have execute c code in terminal
      by using command gcc myprog.c
      But it gives an error that gcc command is not found so tell me fast how to install gcc in fedora.Give me reply fast please;

  • balakrishna` Sep 29, 2010 @ 8:52

    i want c and c++ compilers in fedora 13

    • krishna Jun 4, 2011 @ 14:16

      use yum command :
      yum install gcc gcc-c++
      it may work.i have tested this in my fedora 10.

  • akshay Oct 11, 2010 @ 5:23

    i have a problem that when i type ./a.out for output then some time it runs and some time it shows bash command so wat should i do in order to run program of doublly linked list as it is running in c compiler

  • Oliver Oct 13, 2010 @ 17:23

    Are you kidding? What useful is here? I need to install a C compiler to compile GCC from source. How can I do this?

    • kpormegbe samuel korbla Jan 11, 2011 @ 13:21

      i want to install a compilar

  • Kshitiz KrAkErZ Jan 6, 2011 @ 4:45

    What is here…
    I seek the site frm where I can download the gcc compiler with out requiring its repositories as in a single step….
    provide that…

  • ert Jan 21, 2011 @ 7:18

    Could I install gcc without internet connection?

  • ert Jan 31, 2011 @ 4:53

    I’ve tried to install gcc 4 to linpus. I type the command on the terminal through directory objdir.
    However, I couldn’t finished. the terminal scroll and show, error in path: my documents/gcc4/objdir.
    Anyone can tell the steps?

  • Siddharth Sharma Mar 26, 2011 @ 20:09

    Really nice job buddy… Keep it up

  • gopu Mar 28, 2011 @ 7:07

    how to install .so file in suse linux? & flash in firefox plugin?

  • Tiya Jun 4, 2011 @ 4:26

    i have downloaded gcc-4.6.0.tar.bz2 to my desktop in fedora how to install them??

  • Bogner820 Jun 24, 2011 @ 15:46

    I would consider myself a beginner in the Linux world…I know enough to be dangerous. Very clear instructions. Followed Option 3 and had everything installed in about a minute.

  • Mallesh Jun 29, 2011 @ 1:14

    I want compiler gcc software. plz tell perfect link to download.

  • saraswat Jul 30, 2011 @ 11:00

    I’m using redhat-5,and I face some problem while install vlc or open office ,getting an error acceptable c complier found in $path.

    • saraswat Jul 30, 2011 @ 11:01

      no acceptable c compiler found.

  • tamil Aug 22, 2011 @ 6:03

    plz send gcc download link for redhat enterpris linux server. How to intall this. Send me that steps.

  • redhattt Sep 19, 2011 @ 14:11

    thanx for the installation steps…but i still have problems installing the gcc. during the configuration it says
    checking the correct version of gmp/mpfr/mpc libraries no
    but i have already installed gmp mpfr and mpc as per the version mentioned for installation.
    thank you

  • kelvin Sep 27, 2011 @ 14:01

    i have installed redhat 5 version in windows 7 using vmware.in it c copiler is working fine.but i cant compile c++ programs in it.what is the reason ?do i have to download anything further ?plz reply fast i am in great need now ,,i wiil be very thankful to u

    thanks in advance

  • Mayuri Popat Nov 1, 2011 @ 11:18

    [mayuri@Mayuri Desktop]$ cd ..
    [mayuri@Mayuri ~]$ cd omnetpp-4.1
    [mayuri@Mayuri omnetpp-4.1]$ ./configure
    checking build system type… x86_64-unknown-linux-gnu
    checking host system type… x86_64-unknown-linux-gnu
    configure: ———————————————–
    configure: reading configure.user for your custom settings
    configure: ———————————————–
    checking for icc… no
    checking for gcc… gcc
    checking for C compiler default output file name… a.out
    checking whether the C compiler works… yes
    checking whether we are cross compiling… no
    checking for suffix of executables…
    checking for suffix of object files… o
    checking whether we are using the GNU C compiler… yes
    checking whether gcc accepts -g… yes
    checking for gcc option to accept ISO C89… none needed
    checking for icpc… no
    checking for g++… no
    checking for c++… no
    checking for cxx… no
    checking for xlC… no
    checking whether we are using the GNU C++ compiler… no
    checking whether g++ accepts -g… no
    checking for g++… not found
    configure: error: No C++ compiler found — one is required to build OMNeT++/OMNEST, and also for model development.
    [mayuri@Mayuri omnetpp-4.1]$

  • Mayuri Popat Nov 1, 2011 @ 11:22

    i have the same problem..i have installed centos 6.0 along with windows 7…i can complile c programs but not c++ programs…pls help me for this problem as i have to install omnet++ on centos and it does not work without GNU c++ compliler…

  • jagadeesh Nov 4, 2011 @ 9:02

    thanku…. it helps lot

  • Sadia Jan 3, 2012 @ 11:12

    I am using Redhat Enterprize 5. I want to install gcc compiler. I download gcc-4.6.2.tar.bz.i save it on desktop.can anyone help me how do I install this??

    • Zakaria Mar 14, 2012 @ 13:22

      Use WinSCP to copy the file from desktop to the server. Then extract on the server and install.

  • Raj Jan 8, 2012 @ 12:45

    Hi Friends,

    I need to install oracle on Redhat linux 5.
    But i don’t have rpm packages ,form where can i down load them and how to install them.
    Kindly guide me….


    • Sriharsha Kalluru Jan 9, 2012 @ 11:54

      You can download the RPM’s required for the Oracle installation in Linux from the following website.


  • shubham singhal Jan 14, 2012 @ 7:53

    hello all
    i’ve used this command
    # yum install gcc gcc-c++ autoconf automake
    to install gcc compiler in my fedora16 os.
    but when i compile and run my first c++ program (helloworld.cpp) using command
    gcc input-file.cpp -o output-file (gcc helloworld.cpp -o helloworld)
    it gives error
    helloworld.cpp:3:18: fatal error: conio.h: No such file or directory
    compilation terminated.
    please help..!
    thank you…

  • satya Jan 18, 2012 @ 10:54

    i need one help for your side please tell me the where can i downloaded gcc compiler for Rhel5 64 bit and how to install the process i downloaded so many gcc compilers but its not working properly. i downloaded rpm packages its asking dependencies please help me out this problem guys…

    • satya Jan 31, 2012 @ 5:28

      u r sending one link that is not workng fine.

  • Babu Jan 27, 2012 @ 1:51

    The pre-requisite for installing gcc is to have the ‘C’ compiler but on my RedHat 5.4 system, I don’t see the C compiler. Can someone please point how to get “C” compiler?

  • brijendra Mar 4, 2012 @ 3:01

    I am getting below error , now what alternative i have to install gcc compiler

    [root@brijendra ~]# yum install gcc gcc-c++ autoconf automake
    Gathering header information file(s) from server(s)
    Server: Red Hat Linux 16 - x86_64 - Base
    retrygrab() failed for:
      Executing failover method
    failover: out of servers to try
    Error getting file http://mirror.dulug.duke.edu/pub/yum-repository/redhat/16/x86_64/headers/header.info
    [Errno 4] IOError: 
  • avdhut Mar 20, 2012 @ 6:06

    nice one

  • pelin Apr 10, 2012 @ 14:15

    , i am new c++ user and i would like to download c++ but i couldn’t. please is there anyone who will explain me this process with detail? Thank you.

  • ramkumar Jul 13, 2012 @ 6:08

    I want c and c++ compiler

  • josephine mumbi Sep 6, 2012 @ 7:40

    Thank you very much,the steps were clear and simple.

  • leena Oct 21, 2012 @ 16:08

    I want to know how to install the c software

  • naveen Oct 31, 2012 @ 14:34

    I an trying to install GCC on my linux CentOS 5.3 machine and i can not install gcc using yum because of no inetrnet connection,i downloaded all required rpm files and trying to install using rpm -Uvh package name of gcc,but it is asking so many dependent packages and even i downloaded all after that it is conflicking some packages with linux packages,please could you suggest any document or installation step including with solution if we face any package conflicts with GCC rpm packages

  • priya Dec 6, 2012 @ 9:00

    please install for me c and c++ program

  • aravind.m Dec 27, 2012 @ 13:25

    please hlp me very urgent install c intall for linux

  • suhael Apr 3, 2013 @ 6:21

    hi sir how to install

  • jan Apr 12, 2013 @ 2:01

    [root@localhost ~]# vi hello.c
    [root@localhost ~]# gcc hello.c -o hello
    bash: gcc: command not found
    [root@localhost ~]#

  • aks Jul 28, 2013 @ 10:35


  • Akshay Sep 16, 2014 @ 5:02

    in my pc the program are runing but they are not executin it gies an error that “cant open file for writing”

  • Akshay Sep 16, 2014 @ 5:03

    how to install c++ in linux
    plz rply urgent

  • sreekanth yadav pasula May 19, 2015 @ 20:35

    super…………………….THANK’S A LOT…………………………..

  • vini May 25, 2015 @ 12:09

    how to install c,c++ in my lap

  • 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.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum