Linux gcc install debian

How To Install GCC on Debian 11

In this tutorial, we will show you how to install GCC on Debian 11. For those of you who didn’t know, GCC (GNU Compiler Collection) is a collection of tools used to compile different programming languages’ source code into binary, executables, or libraries. GCC supports a lot of programming languages like C, C++, Java, Objective-C, Go, Fortran, Ada, etc.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘ sudo ‘ to the commands to get root privileges. I will show you through the step-by-step installation of GCC Compiler on a Debian 11 (Bullseye).

Prerequisites

  • A server running one of the following operating systems: Debian 10 or Debian 11.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user . We recommend acting as a non-root sudo user , however, as you can harm your system if you’re not careful when acting as the root.

Install GCC on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update sudo apt upgrade sudo apt install build-essential

Step 2. Installing GCC on Debian 11.

By default, GCC is available in the Debian base repositories and it can be easily installed using the APT package manager. To install GCC on your Debian 11 system, run the following command:

sudo apt install manpages-dev

Now check the installed GCC version using the following command:

Step 3. Compiling Hello World Using GCC.

Once successfully installed, now we create a basic C code source, for example: let’s create a hello world C program and open hello.c text file:

Save and close, then compile it and execute the hello program by running the following command below:

root@idroot.us:~# ./hello Hello, world!

Congratulations! You have successfully installed GCC. Thanks for using this tutorial for installing the latest version of GCC Compiler on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official GCC website.

Читайте также:  Связка ключей linux браузер

If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Источник

Installing C and C++ compiler (GNU GCC Compiler) On Ubuntu/Debian Linux

This post will guide you how to install the GNU C compiler and GNU C++ compiler under Ubuntu/Debian Linux. How do I install C, C++ compiler and Development Tools on Ubuntu 16.04/18.04 Linux. How to Install GNU GCC Compiler and Development Environment under Ubuntu/Debian Operating system. How to install the manpages for C and C++ development on Ubuntu.

What is GCC?

GCC is the GNU compiler collection, and it includes front ends for C, C++, Objective-C, Fortran, Ada, and Go, as well as libraries for these languages (libstdc++,…). GCC was originally written as the compiler for the GNU operating system.

To install GCC and G++ compiler, You need to install the build-essential package, and this package contains a list of packages which are essential for building Ubuntu Development including GCC compiler, G++ compiler, Make, dpkg-dev and other packages.

GCC is the compiler of C program, and G++ is the compiler of C++ program.

Installing Compilers on Ubuntu

You can simply install build-essential package using apt-get command on Ubuntu/Debian Linux, Type:

$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install build-essential

Or you can also use the apt command to install package, type:

$ sudo apt update $ sudo apt upgrade $ sudo apt install build-essential
devops@devops-osetc:~$ sudo apt install build-essential sudo: unable to resolve host devops-osetc [sudo] password for devops: Reading package lists. Done Building dependency tree Reading state information. Done build-essential is already the newest version (12.1ubuntu2). 0 upgraded, 0 newly installed, 0 to remove and 599 not upgraded.

Now you should able to compile C/C++ programs using gcc/G++ compilers.

Checking Versions of Compiler

After you installed the build-essential package on your Ubuntu/Debian Linux system, you can check the installed version of gcc or g++ compiler to check if the compilers are installed properly. Type:

devops@devops-osetc:~$ gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
devops@devops-osetc:~$ g++ --version g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
devops@devops-osetc:~$ make --version GNU Make 4.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Installing the manpages for C and C++ development

To install the manpages for c and c++ development, you can install manpages-dev package, type:

$ sudo apt-get install manpages-dev
devops@devops-osetc:~$ sudo apt-get install manpages-dev sudo: unable to resolve host devops-osetc Reading package lists. Done Building dependency tree Reading state information. Done manpages-dev is already the newest version (4.04-2). 0 upgraded, 0 newly installed, 0 to remove and 599 not upgraded.

Compile C and C++ Program with GNU GCC Compiler

Let’s write down a simple C program to test C compiler, open your vi text editor and appending the following code, and save as fio.c:

Читайте также:  Чем форматировать флешку линукс

Save and close the file. and then execute the below command to compile the fio.c program as an executable file named as fio.type:

then you can run the C profile, type:

devops@devops-osetc:~$ gcc fio.c -o fio devops@devops-osetc:~$ ./fio hello world

You can also write a C++ program named fio.cc via vim editor, and append the following code:

#include using namespace std; int main()

Save and close the file fio.cc, and executing the following command to compile and execute it:

devops@devops-osetc:~$ vim fio.cc devops@devops-osetc:~$ g++ -o fio fio.cc devops@devops-osetc:~$ ./fio Hello world!

Источник

How to Install GCC Compiler on Debian 10 Linux

The GNU Compiler Collection (GCC) is an open-source collection of compilers and libraries supporting C, C++, Objective-C, Fortran, Ada, Go, and D programming languages. The Linux kernel, the GNU utilities, and many other projects are compiled with GCC.

This tutorial explains how to install the GCC compiler on Debian 10, Buster. The same instructions apply for Debian 9 and any Debian-based distribution.

Prerequisites #

To install packages on your Debian system, you must be logged in as a user with sudo privileges .

Installing GCC on Debian #

The default Debian repositories contain a meta-package named build-essential that contains the GCC compiler and other libraries and utilities required for compiling software.

Follow the steps below to install the GCC Compiler Debian 10:

    First, update the packages list:

sudo apt install build-essential

You may also want to install the manual pages that includes documentation about using GNU/Linux for development:

sudo apt-get install manpages-dev

At the time of writing this article, the default version of GCC available in the Debian 10 repositories is 8.3.0 :

gcc (Debian 8.3.0-6) 8.3.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

That’s it. You have successfully installed GCC on your Debian machine.

Читайте также:  Linux permissions in numbers

Compiling a Hello World Example #

Compiling a basic C or C++ program with GCC is pretty straightforward. Open your text editor and create the following file:

#include  int main()   printf ("Hello World!\n");  return 0; > 

Save the file and use the following command to compile it into an executable:

The compiler will create a binary file named hello in the same directory, where the command was executed.

To execute the program run:

The output will look like this:

Conclusion #

You have successfully installed GCC on your Debian 10. For more information about GCC, visit the official GCC Documentation .

If you hit a problem or have feedback, leave a comment below.

Источник

Как установить компилятор GCC в Debian 10 Linux

Коллекция компиляторов GNU (GCC) — это коллекция компиляторов и библиотек с открытым исходным кодом, поддерживающая языки программирования C, C ++, Objective-C, Fortran, Ada, Go и D. Ядро Linux, утилиты GNU и многие другие проекты скомпилированы с помощью GCC.

В этом руководстве объясняется, как установить компилятор GCC в Debian 10, Buster. Те же инструкции применимы для Debian 9 и любого дистрибутива на основе Debian.

Подготовка

Чтобы установить пакеты в вашей системе Debian, вы должны войти в систему как пользователь с привилегиями sudo .

Установка GCC на Debian

Репозитории Debian по умолчанию содержат метапакет с именем build-essential который содержит компилятор GCC и другие библиотеки и утилиты, необходимые для компиляции программного обеспечения.

Выполните следующие действия, чтобы установить компилятор GCC Debian 10:

    Сначала обновите список пакетов:

sudo apt install build-essential

Вы также можете установить справочные страницы, которые включают документацию по использованию GNU / Linux для разработки:

sudo apt-get install manpages-dev

На момент написания этой статьи версия GCC по умолчанию, доступная в репозиториях Debian 10, была 8.3.0 :

gcc (Debian 8.3.0-6) 8.3.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Вот и все. Вы успешно установили GCC на свой компьютер Debian.

Компиляция примера Hello World

Компиляция базовой программы C или C ++ с помощью GCC довольно проста. Откройте текстовый редактор и создайте следующий файл:

#include int main()  printf ("Hello World!n"); return 0; > 

Сохраните файл и используйте следующую команду, чтобы скомпилировать его в исполняемый файл:

Компилятор создаст двоичный файл с именем hello в том же каталоге, где была выполнена команда.

Для выполнения программы запустите:

Результат будет выглядеть так:

Выводы

Вы успешно установили GCC на свой Debian 10. Для получения дополнительной информации о GCC посетите официальную документацию GCC .

Если вы столкнулись с проблемой или хотите оставить отзыв, оставьте комментарий ниже.

Источник

Оцените статью
Adblock
detector