Astra linux установка gcc

Не устанавливается g++

Чтение списков пакетов…
Построение дерева зависимостей…
Чтение информации о состоянии…
Некоторые пакеты невозможно установить. Возможно, вы просите невозможного,
или же используете нестабильную версию дистрибутива, где запрошенные вами
пакеты ещё не созданы или были удалены из Incoming.
Следующая информация, возможно, поможет вам:

Пакеты, имеющие неудовлетворённые зависимости:
g++ : Зависит: g++-6 (>= 6.3.0-9~) но он не будет установлен
E: Невозможно исправить ошибки, у вас отложены (held) битые пакеты.

В чем может быть проблема?

DEVOPS

New member

Пытаюсь установить g++:
sudo apt install g++

Чтение списков пакетов…
Построение дерева зависимостей…
Чтение информации о состоянии…
Некоторые пакеты невозможно установить. Возможно, вы просите невозможного,
или же используете нестабильную версию дистрибутива, где запрошенные вами
пакеты ещё не созданы или были удалены из Incoming.
Следующая информация, возможно, поможет вам:

Пакеты, имеющие неудовлетворённые зависимости:
g++ : Зависит: g++-6 (>= 6.3.0-9~) но он не будет установлен
E: Невозможно исправить ошибки, у вас отложены (held) битые пакеты.

В чем может быть проблема?

oko

New member

to sergunok
Когда-то давно ставил С/С++ на Орла из родного репозитория. Так что если ничего не поменяли, то sudo apt install gcc g++ make решит проблему.
Это при условии, что репы сконфигурированы корректно и в системе не проводилось лишних манипуляций по обновлению сразу из репы астры и сразу нескольких версий дебиан (как тут часто любят, ага).

countmein

New member

sergunok

New member

to sergunok
Когда-то давно ставил С/С++ на Орла из родного репозитория. Так что если ничего не поменяли, то sudo apt install gcc g++ make решит проблему.
Это при условии, что репы сконфигурированы корректно и в системе не проводилось лишних манипуляций по обновлению сразу из репы астры и сразу нескольких версий дебиан (как тут часто любят, ага).

В том-то и дело, что я не трогал настройки репозиториев.
Сделал sudo apt update

Читайте также:  Wifi linux windows driver

И вот такая-вот ошибка:
Чтение списков пакетов…
Построение дерева зависимостей…
Чтение информации о состоянии…
Некоторые пакеты невозможно установить. Возможно, вы просите невозможного,
или же используете нестабильную версию дистрибутива, где запрошенные вами
пакеты ещё не созданы или были удалены из Incoming.
Следующая информация, возможно, поможет вам:

Пакеты, имеющие неудовлетворённые зависимости:
g++ : Зависит: g++-6 (>= 6.3.0-9~) но он не будет установлен
E: Невозможно исправить ошибки, у вас отложены (held) битые пакеты.

Может быть дело в CE? Нужен SE?

Источник

Compile C Program in Linux Using GCC

The full form of GCC is GNU Compiler Collection. GCC has compilers for C, C++, Objective-C, Ada, Go, Fortran and many more programming languages. These are all open source and free to use.

In this article, I will show you how to install GCC and compile C programs in Linux using GCC. I will use Debian 9 Stretch for the demonstration. But I will show you how to install GCC on wide variety of Linux distributions. Let’s get started.

Installing GCC on Ubuntu and Debian GNU/Linux:

On Ubuntu and Debian GNU/Linux distributions, GCC is really easy to install as all the required packages are available in the official package repository of Ubuntu and Debian. There is a meta package called build-essential, which installs everything you need in order to compile C and C++ programs on Ubuntu and Debian GNU/Linux distribution.

First, update the APT package repository cache with the following command:

The APT package repository cache should be updated.

Now install build-essential with the following command:

Now press y and then press to continue.

Now you can check whether GCC is working with the following command:

Installing GCC on Linux Mint:

You can install GCC on Linux Mint the same way as in Ubuntu/Debian as shown in the earlier section of this article.

Installing GCC on CentOS 7 and Fedora:

On CentOS 7 and Fedora, GCC is easier to install as well. The required packages are available in the official package repository of CentOS 7 and Fedora. You can install the Development Tools group to install all the required packages to compile C and C++ programs on CentOS 7 and Fedora.

Читайте также:  Mediatek linux wifi driver

First, update the YUM database with the following command:

YUM database should be updated.

Now install Development Tools group packages with the following command:

Now press y and then press to continue.

If you see this message, just press y and then press .

Now you can check whether GCC is working with the following command:

Installing GCC on Arch Linux:

You can install GCC on Arch Linux too. All the required packages are available in the Arch package repository. Arch also has a meta package base-devel, which you can install to get all the required tools needed to compile C and C++ programs on Arch Linux.

First, update the Pacman database with the following command:

Pacman database should be updated. In my case, it was already up to date.

Now install base-devel package with the following command:

Now press to select all unless you want to install very specific set of packages.

You may see something like this. It’s nothing serious as far as I know. It’s just a package was renamed from pkg-config to pkgconf. So Pacman is asking you whether you want to use the new package and remove the old one. Just press y and then press .

Now press y and then press .

Now check whether GCC is working with the following command:

Writing Your First C Program:

Now let’s write a very simple C program, which we will compile in the next section of this article below using GCC C compiler.

First, create a project directory (I am going to call it hello) with the following command:

Now navigate to the newly created directory with the following command:

Now create a new C source file (I am going to call it main.c) here with the following command:

Now open the file with any text editor (such as vim, nano, gedit, kate etc) of your choice.

To open the file with nano, run the following command:

To open the file with vim, run the following command:

To open the file with Gedit, run the following command:

Читайте также:  Broadcom linux bluetooth drivers

To open the file with Kate, run the following command:

I am going to use Gedit text editor in this article.

Now type in the following lines and save the file.

Here, line 1 includes the stdio.h header file. It has function definition for the printf() function I used on line 4.

Every C program must have a main() function. It is the function that will get called when you run a C program. If you don’t write a main() function, you can’t run the C program. So I wrote a main() function in line 3line 7.

Inside the main() function, I called printf() library function in line 4 to print some text to the screen.

Finally, in line 6, I returned 0 from the program. On Linux world, when a program returns 0, it means the program ran successfully. You can return any integer you like but there are some Linux specific rules on what return value means what.

In the next section, I will show you how to compile the C program with GCC and run it.

Compiling and Running C Programs with GCC:

The command to compile a C source file with GCC is:

NOTE: Here, SOURCE_FILES is a whitespace separated list of C source files. The compiled executable file will be saved as OUTPUT_BINARY in your current working directory.

In our case, the main.c source file doesn’t depend on other C source file, so we can compile it with the following command:

The source file main.c should be compiled and hello executable file should be created as you can see in the screenshot below.

Now, you can run the hello executable binary file as follows:

As you can see, the correct output is printed on the screen.

So that’s basically how you use GCC to compile C programs on Linux. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.

Источник

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