Where is My Linux GNU C or GCC Compilers Are Installed?

by on November 14, 2006 · 26 comments· LAST UPDATED August 12, 2013

in , ,

Where is my GNU C compiler? Where does the GNU C (gcc) compiler reside in the RHEL / Fedora / Debian / Ubuntu / CentOS Linux installation? How do I install GNU c/c++ compiler in Linux operating systems?

The GNU Compiler Collection (GCC) is a compiler system. It was created by the GNU Project supporting various programming languages such as C (gcc), C++ (g++), Objective-C, Objective-C++, Fortran (gfortran), Java (gcj), Ada (GNAT), and Go (gccgo).
Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsGNU gcc
Estimated completion time5m

You need to use the which command to locate c compiler binary called gcc. Usually, it is installed in /usr/bin directory.

Syntax

Open a terminal and then type the following command to see Linux C Compiler location:
$ which gcc
Sample outputs:

/usr/bin/gcc

Display gcc version:

Type the following command
$ gcc -v
Sample outputs:

 Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)

Installing GNU compiler collection

You need to use the up2date or yum or apt-get command to install gcc and required libs.

Note: You must login as root using su - or sudo -s command and then use command as per your distro.

If you are using Red Hat Enterprise Linux version 4.0 or older, type the command:

# up2date gcc

If you are using CentOS/Fedora Linux or RHEL version 5.0 or above, type the command:

# yum install gcc

If you are using Debian /Ubuntu Linux, type the command:

$ sudo apt-get install gcc
OR
# apt-get install gcc

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 26 comments… read them below or add one }

1 Jim January 13, 2009 at 7:41 pm

Hi this help is awesome it helps me a lot , i was looking for this commands in pages of my country(peru) but i didn’t find anything . thanks a lot .

Reply

2 Ash August 22, 2009 at 8:28 am

You just saved my life! Thank you so much for the info…

Reply

3 Roger September 24, 2009 at 11:07 am

Thank you!

Reply

4 JAmesBondRobin October 24, 2009 at 11:37 am

Excellent work… Your help is really appreciate………….
it helped me a lot

Reply

5 xoerk May 17, 2010 at 11:21 am

Thanks….save me tons of time,, :)

Reply

6 sagar sukumar August 30, 2010 at 10:19 am

thank u very much for the help

Reply

7 Mohammad Osman Goni May 3, 2011 at 8:38 am

This tutorial helped me much. Thanks

Reply

8 Bob Ebbert December 13, 2011 at 7:41 pm

1000 Thank Yous.

Reply

9 Eb Bobbert March 18, 2012 at 12:57 am

thx, i just installed it, much appreciated.

Reply

10 nkartik March 23, 2012 at 8:14 am

The smallest question “what is the gcc version” and u had it…Thanx a ton!

Reply

11 shimeles May 7, 2012 at 7:55 am

when I install faad2-2.7 in Optiplex 780 in fedora 13 window the compiler display
shime@localhost softwares]$
[shime@localhost softwares]$ cd faad2-2.7
[shime@localhost faad2-2.7]$ su
[root@localhost faad2-2.7]# ./configure
hecking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking build system type… i686-pc-linux-gnu
checking host system type… i686-pc-linux-gnu
checking for style of include used by make… GNU
checking for gcc… no
checking for cc… no
checking for cl.exe… no
configure: error: no acceptable C compiler found in $PATH
See `config.log’ for more details.
please help me how to solve this problem????

Reply

12 vidhu July 21, 2012 at 9:25 am

hi, when i type the command ‘ yum install gcc’ , i got a reply as ‘you need to be a root to perform this command…”
what does it mean??

Reply

13 Brian November 17, 2012 at 2:05 pm

It means you need to be superuser by using the command:
su

Then it will prompt for a password, then you will be able to install using the same command.

As an alternative log in as the root user.

Reply

14 vidhu July 21, 2012 at 2:03 pm

when i giv the command “yum install gcc”, it says i need to be a root to perform this command… wht shld i do??

Reply

15 Halluka August 2, 2013 at 4:22 pm

It means you need to google “you need to be a root to perform this command…”.

Reply

16 Ucok July 26, 2012 at 2:10 am

I have centos installed,
ls -l glibc-*
-rw-r–r– 1 root root 4596084 Jul 25 15:31 glibc-2.5-34.i386.rpm
-rw-r–r– 1 root root 5459594 Jul 25 15:31 glibc-2.5-34.i686.rpm
-rw-r–r– 1 root root 17249412 Jul 25 15:31 glibc-common-2.5-34.i386.rpm

error when install rpm packet.
rpm -ivh glibc-2.5-34.i386.rpm
error: glibc-2.5-34.i386.rpm: rpmReadSignature failed: region trailer: BAD, tag 15872 type 2047 offset 28672 count 4238
error: glibc-2.5-34.i386.rpm cannot be installed

error when install tar.gz
configure: error: no acceptable C compiler found in $PATH
]# gcc
-bash: gcc: command not found
(gcc not install).

How to install gcc ?
thx a lot

Reply

17 cameron August 29, 2012 at 4:17 am

I had the need to be in root to perform this command error so I thought Id share the solution I found (im using centOS). I used the command – sudo yum install gcc-c++

BUT that is for c++ compiling so for C use sudo yum install gcc

It seems that you need to put sudo in front of the command to use root 0.o maybe.

Reply

18 Brian November 17, 2012 at 2:08 pm

Sudo will raise the priv level of the currently logged in user to execute the task listed after it (you can also find out more with: man sudo), it is like right clicking in Windows and selecting to run as administrator.

Reply

19 Mir December 6, 2012 at 12:46 pm

I have several error to comiple SPEC2006. can you help
specmake: icc: Command not found
Error with make ‘specmake build’
specmake: *** [spec.o] Error 127
Command returned exit code 2
Error with make!

Reply

20 gaurav saini March 24, 2013 at 1:40 pm

how i get my c++ compiler in linux please give me steps n how i will compile my program

Reply

21 vidya March 28, 2013 at 8:12 am

hey what should we give for password? it’s not taking any characters

Reply

22 ad April 8, 2014 at 8:30 am

just enter your password(log in one)
it will not show any thing on display but type your password & press enter .
installation will start

Reply

23 babak April 9, 2013 at 9:03 pm

i want to clean gcc4.3 in ubuntu and install gcc2.96 .
i dont know how do .
please help me .
thanks

Reply

24 Rajesh August 12, 2013 at 12:11 pm

Hi,
I have few problems with my gcc,I feel its not installed at all,when I type the following commands I get the following response

# gcc -v
-bash: gcc: command not found

# sudo apt-get install gcc
sudo: apt-get: command not found

Please let me know how can I install gcc on my RHEL6

Reply

25 sachin kate September 12, 2013 at 10:37 am

sir

i got error msg -can not access archive while insataling gcc
what i have to do

Reply

26 sumit October 14, 2013 at 10:28 am

Hi,
I found below error. Please help.

[root@localhost objdir]# yum install gcc
Loading “rhnplugin” plugin
Loading “installonlyn” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
No Repositories Available to Set Up
Reading repository metadata in from local files
Parsing package install arguments
Setting up repositories
No Repositories Available to Set Up
Reading repository metadata in from local files
No Match for argument: gcc
Nothing to do

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: