HOWTO build/install GCC 3.1 from SRPM w/o replacing GCC 2.96 ?

HOWTO build/install GCC 3.1 from SRPM w/o replacing GCC 2.96 ?

Post by Jim Fische » Wed, 03 Jul 2002 03:03:32

OK. I downloaded the latest and greatest GCC 3.1 SRPM from Redhat's
FTP site:

Now I'd like to build and install GCC 3.1 along side GCC 2.96 on my RH
7.3 system. How is this done? FWIW, when I do the following,

    % cd /usr/src/redhat
    % rpm -Uvh SRPMS/gcc-3.1-7.src.rpm
    % rpm -bb SPECS/gcc31.spec

I end up with i386.rpm's that replace the existing GCC 2.96

FWIW, I don't really care where the resulting i386.rpm binaries install
GCC 3.1 on my system -- e.g., a special directory (e.g.,
/usr/share/gcc3.1), or in the "usual" installation paths (e.g.,
/usr/bin/gcc3, /usr/include/g++-3, /usr/lib/gcc-lib, etc.), whatever.
I just need to make sure the GCC 3.1 installation[1] is functional, and
that it does not replace or corrupt the existing GCC 2.96 installation.

[1] Specifically, gcc and g++ (and their supporting programs [e.g.,
cpp]) need to be functional. I'm not using any of the other compilers in
the GCC 3.1 bundle.

[n.b. I've already downloaded and installed the other prerequisites --
e.g., the latest binutils, the latest glibc, etc. Also, I *need* to
build GCC 3.1 from its sources. Downloading someone else's precompiled
i386 RPMs of GCC 3.1 is not an option for me...]



HOWTO build/install GCC 3.1 from SRPM w/o replacing GCC 2.96 ?

Post by J Haywar » Wed, 03 Jul 2002 12:10:46

> OK. I downloaded the latest and greatest GCC 3.1 SRPM from Redhat's FTP
> site:


That srpm is probably designed to create binary rpm's that install
alongside 2.96. Leaving 2.96 as the default compiler. I have 3.1-5
installed alongside 2.96 on RH 7.3.

I usually get my gcc3 rpm's from here.

        Jim H



1. gcc 2.96 vs. gcc 3.2: namespace, template incompatability

The old code I once wrote in redhat 7.3(gcc 2.96) are no longer
compiled without errors in gcc 3.2 after I upgrade to redhat 8.0.

In gcc 3.2, the compiler always complain that 'cin', 'endl' etc. are
undefined unless I add the line "using namespace std".

In addition, there is also some problem in template, for example, the
code segment below is compiled OK in gcc 2.96, but there are a lot of
errors given by gcc 3.2. And there is still a error after I add "using
namespace std"

$ g++ -o max_string max_string.C
max_string.C: In function `int main()':
max_string.C:37: cannot convert
   std::vector<std::string, std::allocator<std::string> > >' to
   in initialization

// code segment in "C++ Primer" chapter 20 iostream library
#include <string>
#include <algorithm>
#include <iterator>
#include <vector>
#include <iostream>

using namespace std;

bool length_less( string s1, string s2 )
    { return s1.size() < s2.size(); }

template <class InputIterator>
void filter_string( InputIterator first, InputIterator last,
                    string filt_elems = string( "\",?." ))
    for (; first != last; first++) {
        string::size_type pos = 0;
        while ( (pos = (*first).find_first_of(filt_elems, pos))
                != string::npos )
            (*first).erase( pos, 1 );

int main()
    istream_iterator<string> input( cin ), eos;

    vector<string> text;
    // copy is a generic algorithm
    // copy from standard input to text
    copy( input, eos, back_inserter( text ));
    string filt_elems( "\",.?;:" );
    filter_string( text.begin(), text.end(), filt_elems );

    int cnt = text.size();
    // max_element is a generic algorithm
    string *max = max_element( text.begin(), text.end(), length_less
    int len = max->size();

    cout << "The number of words read is " << cnt << endl;
    cout << "The longest word has a length of " << len << endl;
    cout << "The longest word is " << *max << endl;

2. ipchains / fw

3. Upgrade gcc 2.96-98 to gcc 3.2-7 on Redhat 7.2

4. CRONTAB and PS problems

5. How can I completely replace gcc installed by default with new gcc-3.2?

6. v1.4.2 of the slang programmer's library released

7. Problem compiling kernel 2.4.7 with gcc 2.96

8. Two hopefully easy questions

9. gcc 2.96 (??)

10. gcc 2.96 and kernel compile

11. gcc/g++ 2.96?

12. math.h of gcc 2.95/2.96 on redhat 7.3 platform

13. gcc 2.96 and Mandrake 8.0