Gcc 4 как установить на fedora 31
Перейти к содержимому

Gcc 4 как установить на fedora 31

  • автор:

How to Install GNU GCC (C and C++ Compiler) and Development Tools in RHEL/CentOS and Fedora

Nowadays, as a system administrator or engineer you can’t feel satisfied by knowing how to use the CLI and troubleshoot GNU/Linux servers, but will need to go one step further into the development area as well to stay at the top of your game. If you’re considering a career in kernel development or applications for Linux, then C or C++ is the best place to start.

Install C C++ Compiler and Development Tools

In this article we will explain how to install Gnu C and C++ compilers and it’s related Development tools such as automake, autoconf, flex, bison, etc. in Fedora and CentOS / RHEL systems.

What is Compiler?

In simple words, a compiler is a software program that transforms statements written in a source language into a target language that the machine’s CPU can understand and execute.

In Fedora and derivatives (actually, that is true for the entire Linux distro ecosystem as well), the most well-known C and C++ compilers are gcc and g++, respectively, both developed and supported actively by the Free Software Foundation as part of the GNU project.

Installing GCC (C++ Compiler and Development Tools

If gcc and / or g++ and it’s related Development Tools are not installed in your system by default, you can install the latest available from the repositories as follows:

Before we dive into writing C or C++ code, there’s another tool to boost your development toolset that we want to show you.

Speeding up C and C++ Compilations in Linux

When you as part of the development process, have to recompile several times after making changes to the source code it’s great to have a compiler cache to speed up future recompilations.

In Linux, there’s an utility called ccache, which speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again. Besides C and C++, it also supports Objective-C and Objective-C++.

Ccache has only a few limitations: it’s only useful while recompiling a single file. For other types of compilations, the process will end up running the actual compiler. The same thing happens if a compiler flag is not supported. The bright side is that in any event it will not interfere with the actual compilation and will not throw an error – just fall back to the actual compiler.

Let’s install this tool:

and see how it works with an example.

Testing GNU C Compiler with a simple C++ Program

As an example, let’s use a simple C++ program that calculates the area of a rectangle after its length and width have been provided as inputs.

Open your favorite text editor and enter the following code, then save as area.cpp :

To compile the above code into an executable named area in the current working directory use the -o switch with g++:

If you want to take advantage of ccache, just prepend the above command with ccache, as follows:

Then run the binary:

Sample Output

Don’t let this simple example make you think that ccache is not useful. You will come to know what a great tool ccache is when recompiling a large source code file. The same principle applies for C programs as well.

Summary

In this article we have explained how to install and use the GNU compilers for C and C++ in Fedora-based distributions.

In addition, we showed how to use a compiler cache to speed up recompilations of the same code. While you can refer to the online man pages for gcc and g++ for further options and examples, we look forward to hearing from you if you have any questions or comments.

Tutorial Feedback.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Gcc 4 как установить на fedora 31

In this post, i will show quick steps to install gcc on linux Fedora 16 server. The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages. The compiler is designed to support multiple front-ends and multiple back-ends by translating first into Register Transfer Language and from there into assembly code for the target architecture. Assume that you have installed minimal installation type Fedora 16 and has setup your own local yum repository.

To install gcc on Fedora 16, simply run the following command :

Thanks for checking in!

Here you won’t find biased «expert» reviews, forged speed and uptime ratings, deceptive «actual testing» analyses etc. Just plain data backed by real customer reviews, both positive and negative. We’ve been collecting them since 2004.

Nevertheless, some content may include ads and sponsored links. Yeah, passion alone does not pay the rent. This helps us pay for the servers and parsers. Thank you for understanding.

How to install an older version of gcc on Fedora

I tried to install CUDA on Fedora 31 but got stuck at the last step because CUDA officially supports Fedora 29 (gcc 8.2) while the version shipped with Fedora 31 is 9.2, I then installed Pytorch with CUDA support and without much surprise, CUDA support is not present:

I then tried to search for gcc, g++ and gfortran on pkgs, but got stuck in a dependency hell, something like:

I found a bunch helpful links on this post but unfortunately the last version is gcc 7.3 My last option is building from source, but apart from that is there any other option? I’m not sure my computer can handle the compilation in a decent amount of time.

How to update the version of gcc-c++ on Fedora?

I have version 4.4.4 of gcc installed and would like to update to either a specific version or to the latest version. Here is what I have tried:

this tells me that Package gcc-c++-4.4.4-10.fc12.i686 already installed and latest version (not true, there is at least a version 4.8 available).

Next I tried a specific version:

with the result of No Package gcc-c++-4.8.1 available. .

At last I tried to update the package with

with the result No Packages marked for Update .

So how the heck do I update the version of gcc and/or gcc-c++ to be able to compile projects with C++11?

1 Answer 1

The message already installed and latest version is referring to the latest version of the RPM (binary package) for the version of Fedora. It appears that you are using Fedora 12, which is quite outdated. Your best course of action is likely to upgrade to the latest version of Fedora first, then you will have a more recent version of GCC available (4.7.2).

It takes a while for major software like GCC to make it through a distribution’s build and QA process. So if you absolutely must have GCC 4.8.1 now (which seems unlikely given the age of your distribution), then you’ll probably either have to find a third-party package or build it from source yourself. Regardless, I’d still recommend upgrading Fedora to reduce dependency complications.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *