41
votes

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

2 Answers

59
votes
gcc -nostdinc -I/custom/include/path/goes/here

-nostdinc ignores standard C include directories
-nostdinc++ ignores standard C++ include directories

11
votes

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