9

I can see that adding a path to the gcc search path can be done by using the -I flag. However, when using -v I can see that the path is being searched first.

Is there anyway I can have the search path I added, searched at the very end?

3 Answers3

8

The -idirafter option allows you to specify an include directory for consideration only after all regular -I directories and the standard system directories. This is documented here:

https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#Invocation

-idirafter dir

Search dir for header files, but do it after all directories specified with -I and the standard system directories have been exhausted. dir is treated as a system include directory. If dir begins with =, then the = will be replaced by the sysroot prefix; see --sysroot and -isysroot.

Chris Nauroth
  • 9,614
  • 1
  • 35
  • 39
2

There is an explanation here on SO: Manipulating the search path for include files and also here which may help you.

All three methods from above are mentioned in the linked SO post.

Community
  • 1
  • 1
martin
  • 3,149
  • 1
  • 24
  • 35
1

Use the -idirafter option to add a directory to the end of the include search path.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112