This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Can't install gcc 3.2 alongside gcc 2.96 on Red Hat 7.3


Jonathan,

GCC supplies its own set of C++ header files along with its own C++
library, which is why the directory is different for those headers.  The
C++ library is fairly tightly coupled with GCC, so you probable wouldn't
want to try to upgrade that.  An alternative would be to use STLport,
which you might be able to use with the old compiler, but that's fraught
with difficulties as well, so I'm not sure I would recommend that path,
except under certain circumstances.

The second comment below that you are concerned about should not concern
you.  Basically, the C library and headers come with the system.  The
C++ library and headers come with the compiler.  Problems you are having
compiling C++ code will have little to nothing to do with the C library
headers and much more to do with the C++ headers and the compiler's
level of C++ compliance.

In short, if it compiles on another system with the version of GCC that
you are trying to install, it will very likely compile with the one you
are trying to install.

There are, however, a few caveats that you will need to be aware of.
C++ libraries compiled with the old GCC will not be compatible with
libraries or programs compiled with the new GCC.  This means that if
your programs rely on C++ libraries that are installed with the system,
you will not be able to use the ones that are installed.  Rather, you
will have to build your own copy of them with the new compiler and place
them in an appropriate location.  If you're just doing basic C++
programming (that is, not relying on other C++ libraries), you shouldn't
have any problems.

(C libraries, however, are no problem.  They should generally work fine
regardless of which compiler you built them with.)

In addition, C++ program compiled with your new compiler will be
dependent on the C++ library and other GCC libraries that come with the
new GCC.  You will need to do one of three things in order for your
programs to run:

1) Embed the path to the libraries into your libraries and programs that
you build (look at the -R compiler option and -rpath linker option).
2) Place copies of the libraries in one of the directories that your
system looks in by default (or add the directory to your system's
default search path) - not recommended, by the way.
3) Set LD_LIBRARY_PATH to point to the location that GCC's libraries are
installed in before running your programs.

I would recommend either 1 or 3, and prefer 1.  And, if you plan on
installing the programs built with the new compiler onto the system,
you'll want to put a copy of the libraries that come with GCC into a
directory other than your home directory.

If you don't do one of those things, your program will compile fine, but
probably won't run, because it will complain that it can't find
libstdc++.so.5 or something like that.

Basically, you can easily install and use another compiler than the
system default, but it will take a little bit of work - or at least
forethought - to get it to work well, depending on how you intend to use
it and the programs or libraries that you build with it.

Make sense?

Cheers,
Lyle

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Jonathan Watt
Sent: Thursday, February 19, 2004 12:44 PM
To: gcc-help@gcc.gnu.org
Subject: Re: Can't install gcc 3.2 alongside gcc 2.96 on Red Hat 7.3

>>>The include directories are basically the same for both compilers
except 
>>>for
>>>the libstdc++ headers. You should not have to specify any option to
gcc in
>>>order to let it find its specific headers or libraries. 

Why is it different for libstdc++ headers?

> GCC itself does not supply many headers and libraries. Instead it uses
the C
> standard library of the system and other headers/libraries installed
in the
> standard locations (/usr/{include,lib} and /usr/local/{include,lib})
by
> default.

Hmm. I didn't realise that. This could cause problems as my whole reason

for wanting a more up-to-date version of gcc was that the existing one 
couldn't compile the C++ code I am working on. I kept getting error 
messages about certain aspects of the standard library not existing (it 
works using gcc 3.2 on a Mandrake 8.2 box).

Can I add a more up-to-date version of the standard C++ library to gcc 
if I install gcc under my $HOME directory? Which version normally goes 
with gcc 3.2.3? Can anyone tell me how I would get my install of gcc to 
use this library automatically?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]