I need to compile some files with a usage of modified versions of standard library headers. With Visual C++ compiler I will do this by usage of /X (Ignore Standard Include Paths) and /I (Additional Include Directories) parameters. How this should be done with gcc?
2 Answers
gcc -nostdinc -I/custom/include/path/goes/here -nostdinc ignores standard C include directories
-nostdinc++ ignores standard C++ include directories
If you just add -I to your command line you will see (especially if you also add -v) that gcc will look in these folders first before looking in any other folders. So you don't need to add --nostdinc) in order to use an alternative STL library.
In this way STLPort is used:
g++ -I path-to-stlport-include main.cpp -L path-to-stlport-lib -lstlport
3 Comments
okutane
But in some cases it's better not to have standard include paths, so standard headers will not be included instead of one I'm using for replacement in case when that replacement is missing. From my POV it's much better to have compilation error in that case than confusing behavior of successfully compiled unit.
MariuszW
Some documentation for gcc: gcc.gnu.org/onlinedocs/gcc-7.5.0/gcc/…
FrankHB
This would certainly not work for
#include_next in some system headers.