delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq052.html   search  

| Previous | Next | Up | Top |

8.2 GCC can't find C++ headers

Q: I installed all the packages, but GCC complains it can't find iostream.h, _string.h and other C++ headers. Where can I find those header files?

Q: GCC complains about being unable to find Complex.h, Regex.h and other header files which start with a capital letter, and I indeed don't see them in my lang/cxx/ directory. Where are they?

Q: My C++ program needs header files whose filenames exceed the 8+3 DOS filename restrictions, like stdiostream.h and streambuf.h, and GCC cannot find those files. How in the world can I write portable C++ programs??


A: All C++ include files are packaged as part of the GNU C++ compiler distribution zip file, so if you didn't install it, GCC won't find them. Files whose names usually start with a capital letter, on MS-DOS have an underscore `_' prepended so they can be distinguished from complex.h, regex.h and the like under case-insensitive DOS. Change Complex.h to _Complex.h, and String.h to _String.h in your source, and GCC will find them. The same goes for the header iostreamP.h--you should use _iostreamP.h instead. If you don't have the underscore _ on your keyboard, you might find using strclass.h instead of _String.h easier.

Another possibility to handle header files like Complex.h in a portable way is to pass the -remap switch (supported by GCC 2.8.0 and later) to the pre-processor; see the cpp docs and the README.DJGPP file in the GCC distribution, for more info about this feature.

The most probable cause of problems with header files whose names exceed the DOS 8+3 limits is that you are compiling on Windows 9X, but the Long File Names (a.k.a. LFN) support is disabled. DJGPP v2.01 comes with LFN disabled by default on the DJGPP.ENV file. To enable it, set the environment variable LFN to y, like this:


       set LFN=y

If the problems with long names of header files aren't solved by this, it is possible that you unpacked the DJGPP distribution with a program which doesn't support long file names. The solution is to install DJGPP again using a different unzip program.

If you have problems with header files with long filenames, and you run under Windows NT, it usually means that you used an unzip program which supports long file names on NT; unzip again using a DOS unzip program. Alternatively, you could install an LFN driver for Windows NT, see LFN driver for NT, earlier in this FAQ.

Another possible cause for problems with C++ include files is that your source file has a .c extension. GCC then thinks that this is a C program and doesn't instruct the preprocessor to search the include directories specific to C++. Rename your file to .cc or .cpp extension, or call GCC with the -x c++ switch, and the header files will be found. A full list of extension rules which GCC uses to determine the source language can be found in the list of language-specific suffixes, elsewhere in this FAQ.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)