1

I'm trying to install g++ (with gcc already installed) on my Red Hat Enterprise Linux 6.

I've tried the following:

$ yum install g++
$ yum install c++
$ yum install gcc-g++
$ yum install gcc-c++

and nothing gets installed. I've also tried:

$ yum search g++
$ yum search c++

No hits.

What's up?

slm
  • 369,824
  • This question seems to be answered here already http://unix.stackexchange.com/questions/24878/how-do-i-install-g-on-rhel6 – Cristian Măgherușan-Stanciu Nov 23 '13 at 20:15
  • Try yum search gcc | grep ++. – goldilocks Nov 23 '13 at 20:20
  • the problem is that gcc-c++ does not exist in the repository... the question wasn't answered because they didn't say what to do afterwards when you can't find it. – user52964 Nov 23 '13 at 20:47
  • Your conclusion isn't quite right. This is a duplicate, IMO, to that Q. I've added further details, but if you're using RHEL w/ a up to date contract with RH, then this package should be accessible in the official repositories. – slm Nov 23 '13 at 21:12

1 Answers1

0

You can use commands such as repoquery <string> or yum search <string> to search for packages that are available in your repositories.

Examples

$ repoquery 'gcc*'
gcc-0:4.5.1-4.fc14.x86_64
gcc-c++-0:4.5.1-4.fc14.x86_64
gcc-gfortran-0:4.5.1-4.fc14.i686
gcc-gfortran-0:4.5.1-4.fc14.x86_64
gcc-gnat-0:4.5.1-4.fc14.x86_64
gcc-java-0:4.5.1-4.fc14.x86_64
gcc-objc-0:4.5.1-4.fc14.x86_64
gcc-objc++-0:4.5.1-4.fc14.x86_64
gccxml-0:0.9.0-0.6.20110211.fc14.x86_64

Or this:

$ yum search gcc | grep '^gcc'
gcc-gnat.x86_64 : Ada 95 support for GCC
gcc-objc.x86_64 : Objective-C support for GCC
gcc-objc++.x86_64 : Objective-C++ support for GCC
gccxml.x86_64 : XML output extension to GCC
gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
gcc-c++.x86_64 : C++ support for GCC
gcc-gfortran.i686 : Fortran support
gcc-gfortran.x86_64 : Fortran support
gcc-java.x86_64 : Java support for GCC

If neither of these search returns any matches, or the "g++" results are missing from them, then you'll need to add a repository to RHEL that does contain these packages.

As always you can find out what repositories you're configured to use with this command, for example, here are the 1st 15 that I have on my Fedora system:

$ yum repolist | head -15
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
repo id                    repo name                                      status
Dropbox                    Dropbox Repository                                  4
adobe-linux-i386           Adobe Systems Incorporated                         17
adobe-linux-x86_64         Adobe Systems Incorporated                          2
fedora                     Fedora 14 - x86_64                             22,161
google-chrome              google-chrome                                       3
google-earth               google-earth                                        1
google-talkplugin          google-talkplugin                                   1
lamolabs                   LamoLabs Repo                                      58
lamolabs-noarch            LamoLabs Repo                                       2
nautilus-flickr-uploader   Nautilus Flickr Uploader for Fedora 14              3
rpmfusion-free             RPM Fusion for Fedora 14 - Free                   411
rpmfusion-free-updates     RPM Fusion for Fedora 14 - Free - Updates         642

RHEL

Since you're using RHEL I think things are slightly different for you. I'd consult the official documentation from Redhat since you're paying for the support contract anyway.

According to this page, 2.2. GNU C++ Compiler, you can do the following to install g++.

excerpt

2.2.1. Installing the C++ Compiler

In Red Hat Developer Toolset, the GNU C++ compiler is provided by the devtoolset-1.1-gcc-c++ package, and is automatically installed with the devtoolset-1.1 package as described in Section 1.5, “Installing Red Hat Developer Toolset”.

2.2.2. Using the C++ Compiler

To compile a C++ program on the command line, run the g++ compiler as follows: scl enable devtoolset-1.1 'g++ -o output_file source_file...' This creates a binary file named output_file in the current working directory. If the -o option is omitted, the g++ compiler creates a file named a.out by default.

When you are working on a project that consists of several source files, it is common to compile an object file for each of the source files first and then link these object files together. This way, when you change a single source file, you can recompile only this file without having to compile the entire project. To compile an object file on the command line, run the following command:

    scl enable devtoolset-1.1 'g++ -o object_file -c source_file'

This creates an object file named object_file. If the -o option is omitted, the g++ compiler creates a file named after the source file with the .o file extension. To link object files together and create a binary file, run:

    scl enable devtoolset-1.1 'g++ -o output_file object_file...'

Note that you can execute any command using the scl utility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset g++ as default:

    scl enable devtoolset-1.1 'bash'
slm
  • 369,824
  • yum search gcc | grep '^gcc' Repo rhel-6-desktop-rpms forced skip_if_unavailable=True due to: /etc/rhsm/ca/redhat-uep.pem Repo rhel-6-desktop-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/4868405323262525264-key.pem Repo rhel-6-client-rhev-agent-rpms forced skip_if_unavailable=True due to: /etc/rhsm/ca/redhat-uep.pem Repo rhel-6-client-rhev-agent-rpms forced skip_if_unavailable=True due to: /etc/pki/entitlement/4868405323262525264-key.pem gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...) – user52964 Nov 23 '13 at 21:05
  • @user52964 - since you're using RHEL you likely have a support contract from RH for this instance, I would investigate this issue with your administrators. There is likely something up with either the status of your contract, this box, or your environment. – slm Nov 23 '13 at 21:10