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


lrtaylor@micron.com wrote:
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 can't find the -R comiler and -rpath linker options. I searched the option summary page for gcc 3.2.3:


http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Option-Summary.html

I also searched the same page for gcc 3.3.2 just in case they were new. I did notice the -static-libgcc option though, but I don't think I can use it since I need to be able to handle exceptions thrown by the standard C++ (and another) library.

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

Thanks for taking the time to write all the above, that has cleared up some of the mystery of how things work.


I installed gcc 3.2.3 into my home directory /home/jwatt and tried to build my program. Unfortunately certain things are causing problems. First of all including <ostream> and <limits> doesn't seem to work despite files by these names existing in /home/jwatt/gcc/include/c++/3.2.3 and gcc -v says that, that directory is the first directory searched. Another issue is that I am being told that std::left is not declared whereas compiling with gcc 3.2 on my other machine it was fine.

To test that gcc would be able to find its libraries I created a small C++ test file called test.cpp with the following content.

#include <iostream>

int main()
{
  char buf[255];
  std::cout << "enter a value: ";
  std::cin >> buf;  // I know, just build testing
  std::cout << "you entered: " << buf << std::endl;
  return 0;
}

using 'gcc test.cpp' causes errors at the linking stage, the first being "undefined reference to 'std::cout'".

Has anyone any ideas as to what might be causing these problems?

Thanks again Lyle,

Jonathan


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