Debian Linux Install GNU GCC Compiler and Development Environment

by on February 26, 2009 · 17 comments· LAST UPDATED October 16, 2013

in , ,

How do I install GNU/GCC compiler and related tools (such as make, debugger, man pages) collection under Debian Linux system using command line options?

You need to install following packages on Debian and Ubuntu Linux:

[a] build-essential package - Installs the following collection to compile c/c++ program on Debian/Ubuntu Linux:

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion time10m
  1. libc6-dev - C standard library.
  2. gcc - C compiler.
  3. g++ - C++ compiler.
  4. make - GNU make utility to maintain groups of programs.
  5. dpkg-dev - Debian package development tools.

Basically, build-essential package contains an informational list of packages which are considered essential for building Debian packages including gcc compiler, make and other required tools. This package also depends on the packages on that list, to make it easy to have the build-essential packages installed.

Installation

Open the Terminal and then type the following apt-get command as root user:
# apt-get update && apt-get upgrade
# apt-get install build-essential

OR
$ sudo apt-get install build-essential
Sample outputs:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  dpkg-dev fakeroot g++ g++-4.7 gcc gcc-4.7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libc-dev-bin libc6-dev libdpkg-perl
  libfile-fcntllock-perl libitm1 libstdc++6-4.7-dev libtimedate-perl linux-libc-dev make manpages-dev
Suggested packages:
  debian-keyring g++-multilib g++-4.7-multilib gcc-4.7-doc libstdc++6-4.7-dbg gcc-multilib autoconf automake1.9 libtool flex bison gdb gcc-doc gcc-4.7-multilib
  libmudflap0-4.7-dev gcc-4.7-locales libgcc1-dbg libgomp1-dbg libitm1-dbg libquadmath0-dbg libmudflap0-dbg libcloog-ppl0 libppl-c2 libppl7 binutils-gold glibc-doc
  libstdc++6-4.7-doc make-doc
The following NEW packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-4.7 gcc gcc-4.7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libc-dev-bin libc6-dev libdpkg-perl
  libfile-fcntllock-perl libitm1 libstdc++6-4.7-dev libtimedate-perl linux-libc-dev make manpages-dev
0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
Need to get 26.5 MB of archives.
After this operation, 67.6 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrors.kernel.org/debian/ stable/main libitm1 amd64 4.7.2-5 [36.6 kB]
Get:2 http://mirrors.kernel.org/debian/ stable/main libc-dev-bin amd64 2.13-38 [224 kB]
.....
....
....
Setting up manpages-dev (3.44-1) ...
Setting up g++-4.7 (4.7.2-5) ...
Setting up g++ (4:4.7.2-1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (11.5) ...
Setting up libstdc++6-4.7-dev (4.7.2-5) ...

Verify installation

You can verify gcc compiler and make tool using the following syntax:
# whereis gcc make
# gcc -v
# make -v

Sample outputs:

gcc: /usr/bin/gcc /usr/lib/gcc /usr/bin/X11/gcc
make: /usr/bin/make /usr/bin/X11/make /usr/share/man/man1/make.1.gz
...
..
gcc version 4.7.2 (Debian 4.7.2-5)
...
..
GNU Make 3.81
..

Now, you should able to compile software, create Debian packages or simply write a code using C / C++ compilers.

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

{ 17 comments… read them below or add one }

1 Asanga Udugama September 27, 2009 at 5:33 pm

To get the basic development related man pages type;

# apt-get install manpages-dev

Reply

2 Rikard December 5, 2009 at 1:11 am

Worked Perfectly!! Thanks.

Reply

3 daniel February 4, 2010 at 3:45 pm

thx for the info.
this site is my main linux source.
cheers

Reply

4 Jaime Montoya May 3, 2010 at 5:46 pm

Thank you so much! It works perfectly.

Reply

5 master June 17, 2010 at 9:38 am

hello. i can`t use apt-get, becouse he cannot do the updates. i think the update server for apt-get its old. how i fix this problem ?

0% [Conectando a mirrors.ubv.edu.ve (167.134.102.17)]

Reply

6 prosys August 4, 2010 at 10:29 am

master
if you are using linux debian you must go terminal administrator.
you have my seem problem.

Reply

7 andrew April 14, 2011 at 3:22 pm

so apt-get doesn’t know about “groups” like yum does ?

Reply

8 Kay Marill November 15, 2011 at 8:35 pm

When i try to do apt-get install build-essential i get the following message:

Media change: please insert the disc labeled
‘Debian GNU/Linux 5.0.5 _Lenny_ – Official i386 CD Binary-1 20100626-17:37′
in the drive ‘/cdrom/’ and press enter

I never had a disc.. so i can’t insert it now.. not sure what to do. can anyone help, please (i am very new to this so a little slow)

Thanks!

Reply

9 indra najwa November 18, 2011 at 2:11 pm

Hi Kay,
Just edit your apt source list, located at /etc/apt, by typing this :
(as root) gedit /etc/apt/sources.list
Then put a # in the beginning line that says deb cdrom:[Debian GNU/Linux 6.0.0 _Squeeze_ – Official i386 CD Binary-1 20110205-17:27]/ squeeze main==>example from my sources.list

Save the file. Still as root type apt-get update. Then you can try install/upgrade again.

Reply

10 Dani Voi March 19, 2012 at 2:09 pm

Thanks! works great

Reply

11 Aaron B September 1, 2012 at 10:45 pm

So many things I try to install have errors and complications at every turn on this new debian system. A real pain in the butt. Well I guess I wanted to learn linux so this is what it’s all about
Here is what I get when i try to run your apt-get install build-essential
The following packages have unmet dependencies:
initscripts : Breaks: console-setup (< 1.74) but 1.68+squeeze2 is to be installed
Breaks: nfs-common (< 1:1.2.5-3) but 1:1.2.2-4squeeze2 is to be installed
libglib2.0-0 : Breaks: eog (< 3.2.2-3) but 2.30.2-1 is to be installed
network-manager : Recommends: crda but it is not going to be installed
Breaks: network-manager-gnome (< 0.9) but 0.8.1-2 is to be installed
E: Broken packages
root@AaronsPC:/home/aaron/cmake-2.8.9/cmake-build#

Reply

12 Aaron September 1, 2012 at 10:47 pm

This is what i get when trying build-essential

The following packages have unmet dependencies:
initscripts : Breaks: console-setup (< 1.74) but 1.68+squeeze2 is to be installed
Breaks: nfs-common (< 1:1.2.5-3) but 1:1.2.2-4squeeze2 is to be installed
libglib2.0-0 : Breaks: eog (< 3.2.2-3) but 2.30.2-1 is to be installed
network-manager : Recommends: crda but it is not going to be installed
Breaks: network-manager-gnome (< 0.9) but 0.8.1-2 is to be installed
E: Broken packages

Reply

13 k4 September 11, 2012 at 8:32 am

To make update work You have to update file:
/etc/apt/sources.list

Mine looks like that:

deb http://ftp.pl.debian.org/debian/ squeeze main
deb-src http://ftp.pl.debian.org/debian/ squeeze main

deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main

Reply

14 Benno November 3, 2012 at 9:47 pm

Is nice, installation was successful on my KDE debian using the above instructions. The Debian Linux which was installed on my nx9105 hp laptop using Debian iso taken from the debian site: http://www.debian.org/

Reply

15 mrfungus July 15, 2013 at 5:03 am

Thank you very much sir (or lady). You deserve 100 internets for this

Reply

16 dinesh March 21, 2014 at 5:56 pm

thanks, its working .

Reply

17 Aris Krisna November 17, 2014 at 5:19 am

Great . Its Work !!

Thx …

Reply

Leave a Comment

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

Previous Faq:

Next Faq: