install g ++ no RHEL 6 [duplicado]

1

Estou tentando instalar o g ++ (com gcc já instalado) no meu Red Hat Enterprise Linux 6.

Eu tentei o seguinte:

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

e nada é instalado. Eu também tentei:

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

Sem hits.

O que aconteceu?

    
por user52964 23.11.2013 / 21:02

1 resposta

0

Você pode usar comandos como repoquery <string> ou yum search <string> para procurar pacotes que estão disponíveis em seus repositórios.

Exemplos

$ 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

Ou isto:

$ 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

Se nenhuma dessas pesquisas retornar nenhuma correspondência ou se os resultados " g ++ " estiverem ausentes, será necessário adicionar um repositório ao RHEL que contenha esses pacotes.

Como sempre, você pode descobrir quais repositórios você está configurado para usar com este comando, por exemplo, aqui estão os primeiros 15 que eu tenho no meu sistema Fedora:

$ 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

Como você está usando o RHEL, acho que as coisas são um pouco diferentes para você. Eu consultaria a documentação oficial da Redhat, já que você está pagando pelo contrato de suporte.

De acordo com esta página, 2.2. Compilador GNU C ++ , você pode fazer o seguinte para instalar o g ++.

trecho

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'
    
por 23.11.2013 / 21:20

Tags