Bryan Murdock wrote:
I'm trying to compile some C++ stuff on a Red Hat 8 machine. I get the error:
fstream.h: No such file or directory
so I did this:
locate fstream.h
and got this:
/usr/include/c++/3.2/backward/fstream.h
So it looks like I need to get /usr/include/c++/3.2/backward into the include path for gcc somehow. Can anyone remind me how that is done?
If this is your own code, pay close attention below. If not, read enough to understand why fstream.h is in .../3.2/backward/ and then figure out why .../3.2/backward/ isn't in the default include path (it should be).
I kind of thought it should be. I've really hacked up the environment on this machine (long story), so I won't be surprised if I messed up some original setting somewhere to remove this from default include path.
The headers in .../3.2/backward/ are for backwards compatibility only. Eg. old gcc-2.* code that has #include <fstream.h> and others (see below) scattered liberally throughout and you don't want to change them, yet. You eventually should. If this is someone else's project and is packaged for gcc-3.*, I would consider this a bug (since even if it does compile, it's going to be shouting all over the place) and notify the package maintainer.
Well, it's a long story, but this code is only "officially" supported on RH 7.2...It's not real critical that I even get it working on Linux, I was just having an even harder time with HP-UX...but I think I got that one solved now...anyways...
All the backwards compatible header does is shoves a warning and then includes the new version (from new name). The new names just drop the '.h'. So in my new gcc-3.* code I have:
#include <fstream>
not
#include <fstream.h>
This new naming is for all the standard OO libraries (*stream, and STL libraries such as vector, and so forth). For a complete list, just
find /usr/include/c++/3.2/backward/ -iname '*.h'
Any questions?
Thanks for this helpful explanation. The only question I have is, where does this "default include path" come from so I can make sure and keep it in my environment. Oh, here is another one, could I just do a big search and replace to change all fstream.h's to fstream (and repeat for any other old style #includes) to fix this?
Bryan
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
