- Hello World — installing GCC on RHEL 7
- 1. Enable necessary software repositories
- 2. Setup your development environment
- 3. Hello World and your first application
- Working with the Red Hat Developer Toolset and Software Collection packages
- Permanently adding DTS to your development environment
- Red Hat Linux
- Story [ ]
- Features [ ]
Hello World — installing GCC on RHEL 7
In this tutorial, you will install the GNU Compiler Collection 8.2 from the Red Hat Developer Toolset (DTS) and build a simple C++ Hello World application. This tutorial should take less than 30 minutes to complete.
Before you begin, you will need a current Red Hat Enterprise Linux 7 workstation or server subscription that allows you to download software and get updates from Red Hat. If you don’t have an active subscription, register and obtain the RHEL Developer Suite (includes RHEL server) from here.
If you encounter difficulties at any point, see Troubleshooting and FAQ.
1. Enable necessary software repositories
In this step, you will configure your system to obtain software, including the Red Hat DTS, latest dynamic languages, and open source databases from the Red Hat Software Collection repository by using the command line interface.
You can add or remove software repositories from the command line using the subscription-manager tool as the root user. Use the —list option to view the available software repositories and verify that you have access to RHSCL, which includes DTS:
$ su - # subscription-manager repos --list | egrep devtools
If you don’t see any RHSCL repositories in the list, your subscription might not include it. See Troubleshooting and FAQ for more information.
If you are using a desktop edition of Red Hat Enterprise Linux, change -server- to -desktop- in the following commands:
# subscription-manager repos --enable rhel-server-devtools-7-rpms # subscription-manager repos --enable rhel-7-server-optional-rpms
2. Setup your development environment
In this next step you will use a single command to download and install GCC 8.2, and other development tools that are part of Red Hat Developer Toolset. The length of time this step takes depends on the speed of your Internet connection and your system. With a reasonably fast connection, this step should complete in well under 5 minutes.
To install all components, type:
$ su - # yum install devtoolset-8
If you want to install a subset of components, see the instructions here.
Note: You will still use devtoolset-8 as the name of the software collection in all scl commands. Only the name of the meta-package to be installed by yum changes.
3. Hello World and your first application
Using DTS C++ from the command line
The GNU C++ compiler is run with the command, g++. You need to add DTS to your environment with scl enable in a Terminal window. Also see Permanently adding DTS to your Development Environment for more information.
$ scl enable devtoolset-8 bash
Now create hello.cpp using a text editor such as vi , nano , or gedit with the following content:
#include using namespace std; int main(int argc, char *argv[])
Now compile and run the program:
$ g++ -o hello hello.cpp $ ./hello Hello, Red Hat Developer Program World!
For more information, see the GNU C++ Compiler section of the Red Hat Developer Toolset 8 User Guide.
Docker-formatted container images
Docker-formatted container images can be used to run Red Hat Developer Toolset components inside virtual software containers, thus isolating them from the host system and allowing for their rapid deployment. For detailed description of the Red Hat Developer Toolset docker-formatted container images and Red Hat Developer Toolset dockerfiles , see Using Red Hat Software Collections Container Images.
Working with the Red Hat Developer Toolset and Software Collection packages
The Red Hat Developer Toolset is delivered as a set of packages in the Red Hat Software Collection. The software packages in RHSCL are designed to allow multiple versions of software to be installed concurrently. To accomplish this, the desired package is added to your runtime environment as needed with the scl enable command. When scl enable runs, it modifies environment variables and then runs the specified command. The environmental changes only affect the command that is run by scl and any processes that are run from that command. The steps in this tutorial run the command bash to start a new interactive shell to work in the updated environment. The changes aren’t permanent. Typing exit will return to the original shell with the original environment. Each time you login, or start a new terminal session, scl enable needs to be run again.
While it is possible to change the system profile to make RHSCL packages part of the system’s global environment, this is not recommended. Doing this can cause conflicts and unexpected problems with other applications because the system version of the package is obscured by having the RHSCL version in the path first.
Permanently adding DTS to your development environment
To make DTS a permanent part of your development environment, you can add it to the login script for your specific user ID. This is the recommend approach for development, because only processes run under your user ID will be affected.
Using your preferred text editor, add the following line to the end of ~/.bashrc :
source scl_source enable devtoolset-8
After logging out and logging back in again, you can verify that the DTS GCC is in your path by running which g++ or g++ —version .
$ which g++ /opt/rh/devtoolset-4/root/usr/bin/g++
$ g++ -v g++ (GCC) 8.2 20181112 (Red Hat 8.2.1-0)
Red Hat Linux
Red Hat Linux was a Linux distribution, a GNU/Linux based operating system, developed by the Red Hat company from 1995 to 2004, one year after the birth of the two successors: Red Hat Enterprise Linux oriented to the needs of companies and equipped commercial support, and Fedora with the latest software and developed by the volunteer community. The renowned RPM packet manager, adopted by several distributions such as Suse and Mandriva, was specially developed for Red Hat Linux and originally named Red Hat Package Manager.
Story [ ]
The first release of Red Hat was released on November 3, 1994 with an announcement on the «comp.os.linux.announce» newsgroup.
After 2004, it was developed as Red Hat Enterprise Linux (often abbreviated RHEL), renumbering 3 versions.
The latest version of Red Hat is Shrike’s version 9, March 31, 2003, which corresponds to Red Hat Enterprise Linux 3. It should be noted that there has never been a Red Hat Enterprise Linux 1, while in March 2002 Red Hat Enterprise Linux 2.1 was released for Red Hat 7.2.
Features [ ]
Red Hat was the first distribution to use the RPM format as a package management system. Over time it served as a starting point for many other distributions.
The main novelties of the Red Hat distribution are two:
- The most important is the marketing of the product which represented the possibility of spreading the software red hat to other recipients that had not been considered before.
- It is about the structure of distribution updates. Marc Ewing explains the same «inventor»: «Before the appearance of Red Hat, no one ever thought about updating any new GNU/Linux distribution; every time you had to reinstall and it was a major drawback. Incremental updating of the machine was also a difficult task. «