Search code examples
gccincludemultiple-versions

How do /usr/include files (e.g. string.h) relate to gcc version?


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?


Solution

  • 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.