Debian Linux Install GNU GCC Compiler and Development Environment

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 the following packages on a Debian and Ubuntu Linux:
build-essential package – Installs the following collection to compile c/c++ program on Debian/Ubuntu Linux:
Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Time10m

ADVERTISEMENTS

  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.

Debian install gcc and friends
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 or use the apt command:
$ sudo apt-get update
$ sudo apt-get install build-essential

OR
$ sudo apt update
$ sudo apt 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.

How do I install dev man pages?

Type the following command:
$ sudo apt-get install manpages-dev
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  manpages
Suggested packages:
  man-browser
The following NEW packages will be installed:
  manpages manpages-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,134 kB of archives.
After this operation, 5,042 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages all 4.04-2 [1,087 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages-dev all 4.04-2 [2,048 kB]
Fetched 3,134 kB in 6s (500 kB/s)                                         
Selecting previously unselected package manpages.
(Reading database ... 22189 files and directories currently installed.)
Preparing to unpack .../manpages_4.04-2_all.deb ...
Unpacking manpages (4.04-2) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../manpages-dev_4.04-2_all.deb ...
Unpacking manpages-dev (4.04-2) ...
Setting up manpages (4.04-2) ...
Setting up manpages-dev (4.04-2) ...

Verify installation by reading some man pages:
$ man ls
$ man printf

See also
  • Man pages: apt(8)
This entry is 2 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
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdig host ip nmap
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w

ADVERTISEMENTS
25 comments… add one
  • Asanga Udugama Sep 27, 2009 @ 17:33

    To get the basic development related man pages type;

    # apt-get install manpages-dev

  • Rikard Dec 5, 2009 @ 1:11

    Worked Perfectly!! Thanks.

  • daniel Feb 4, 2010 @ 15:45

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

  • Jaime Montoya May 3, 2010 @ 17:46

    Thank you so much! It works perfectly.

  • master Jun 17, 2010 @ 9:38

    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)]

    • Zet Iria Feb 18, 2016 @ 13:10

      Usually you have to change the mirror from where Deb gets the updates/upgrades/repo. It can be done via modifying in /etc/apt/sources.list
      Choose the mirror it fits best, usually the one from your country

      the line that you should add in sources must look like this ( give you the Romanian mirror ) :

      http://www.debian.org/debian/ free stretch contrib main

      Also is better to comment ( # ) the previous ( not working ) source.

  • prosys Aug 4, 2010 @ 10:29

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

  • andrew Apr 14, 2011 @ 15:22

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

  • Kay Marill Nov 15, 2011 @ 20:35

    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!

    • indra najwa Nov 18, 2011 @ 14:11

      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.

      • Dani Voi Mar 19, 2012 @ 14:09

        Thanks! works great

  • Aaron B Sep 1, 2012 @ 22:45

    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#

  • Aaron Sep 1, 2012 @ 22:47

    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

  • k4 Sep 11, 2012 @ 8:32

    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

  • Benno Nov 3, 2012 @ 21:47

    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/

  • mrfungus Jul 15, 2013 @ 5:03

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

  • dinesh Mar 21, 2014 @ 17:56

    thanks, its working .

  • Aris Krisna Nov 17, 2014 @ 5:19

    Great . Its Work !!

    Thx …

  • MaJid May 1, 2015 @ 18:48

    Hi there,
    I’ve a problem which I hope you can help me. As I do:
    > apt-get install update
    I get this error:
    > apt-get: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20′ not found (required by apt-get)
    > apt-get: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20′ not found (required by /usr/lib/x86_64-linux-gnu/libapt-private.so.0.0)
    I’m newbie and I couldn’t solve the problem! I would appreciate if someone helps me.

    • Garett M Oct 7, 2015 @ 4:05

      MaJid you have a broken system i recommend doing a clean install of debian.

      Backup all needed files and reinstall.

  • nprathap Oct 10, 2016 @ 5:33

    In order to make it work on Debian8 Jessie please use the following repo:
    deb http://ftp.de.debian.org/debian jessie main

  • Stoyan Stoyanov Dec 27, 2016 @ 4:05

    Cool!
    one comment – you will be needing a debugger and the headers.
    A build system can go without GDB, but it needs headers/dev version of whatever :)
    all best and happy holidays!

  • james Apr 4, 2017 @ 23:53

    hi, i want to install backports in my kali computer but i got this message :
    cc1: some warnings being treated as errors
    /usr/src/linux-headers-4.9.0-kali3-common/scripts/Makefile.build:298: recipe for target ‘/root/backports-4.4.2-1/compat/main.o’ failed
    make[8]: *** [/root/backports-4.4.2-1/compat/main.o] Error 1
    /usr/src/linux-headers-4.9.0-kali3-common/scripts/Makefile.build:549: recipe for target ‘/root/backports-4.4.2-1/compat’ failed
    make[7]: *** [/root/backports-4.4.2-1/compat] Error 2
    /usr/src/linux-headers-4.9.0-kali3-common/Makefile:1507: recipe for target ‘module/root/backports-4.4.2-1’ failed
    make[6]: *** [_module_/root/backports-4.4.2-1] Error 2
    Makefile:150: recipe for target ‘sub-make’ failed
    make[5]: *** [sub-make] Error 2
    Makefile:8: recipe for target ‘all’ failed
    make[4]: *** [all] Error 2
    Makefile.build:6: recipe for target ‘modules’ failed
    make[3]: *** [modules] Error 2
    Makefile.real:88: recipe for target ‘modules’ failed
    make[2]: *** [modules] Error 2
    Makefile:40: recipe for target ‘modules’ failed
    make[1]: *** [modules] Error 2
    Makefile:30: recipe for target ‘default’ failed
    make: *** [default] Error 2

    plz…help

  • Namrata Sep 2, 2017 @ 1:01

    # apt-get update && apt-get upgrade
    # apt-get install build-essential
    Installed above command but still gcc compiler is not installed
    Please help

  • Oscar Dec 9, 2017 @ 20:43

    Thanks, It’s very useful!
    saludos

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.