Debian Linux Install GNU GCC Compiler and Development Environment

Configurare noua (How To)

Situatie

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.

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

Solutie

Tip solutie

Permanent

Voteaza

(2 din 6 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?