0

I have a Kubuntu 11.10 system with Eclipse-CDT Indigo. gcc-4.6 was installed along with Eclipse. I have since installed gcc-4.4 and gcc-4.2 via Ubuntu packages.

I can switch the /usr/bin/gcc symlink to 4.4 or 4.6 and Eclipse builds my code either way. However when I set the symlink to use gcc-4.2 I get the following error (and many more):

In file included from /usr/include/c++/4.2/cstring:52,
             from /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h:47,
             from /usr/include/c++/4.2/iosfwd:45,
             from /usr/include/c++/4.2/ios:43,
             from /usr/include/c++/4.2/ostream:45,
             from /usr/include/c++/4.2/iostream:45,
             from ../ProjStructure.h:4,
             from ../Scanner.h:3,
             from ../Scanner.cpp:1:
/usr/include/string.h:29: error: ‘__BEGIN_DECLS’ does not name a type

So it appears that the string.h I have in /usr/include expects __BEGIN_DECLS to be defined by one of the compiler specific includes.

/usr/include/string.h comes from the libc6-dev package, which does not seem to have compiler specific versions. I expected the package system to handle this and install all the right versions of things.

I've read the GNU documents on multiple versions of GCC, but they don't say anything about include files/directories.

What am I doing wrong here?

Steve Fallows
  • 6,274
  • 5
  • 47
  • 67

1 Answers1

2

From which Ubuntu is your gcc-4.2 package?

It is probably from an older Ubuntu release. New Ubuntu releases have changed some header and library directories, which break older compilers.

chill
  • 16,470
  • 2
  • 40
  • 44
  • I added 'hardy' (8.04) to my repo list to get it. – Steve Fallows Nov 11 '11 at 20:54
  • @SteveFallows, try running `gcc -v -x c /dev/null`, with newer GCC's you will see `/usr/include/x86_64-linux-gnu` in the search path, with 4.2 you will probably not see it. Similar for libraries, new version will include `/usr/lib/x86_64-linux-gnu` in the library search paths, older version won't. Perhaps you could fiddle with `-I` and `-L` options go achieve something, but I personally wouldnt bother :) – chill Nov 11 '11 at 21:02
  • Thanks. Since I already have an install of Kubuntu 10.4 in which gcc-4.2 works, I think I'll just install Eclipse there and go with that. – Steve Fallows Nov 11 '11 at 21:47