Search code examples
unixmakefilecompilationconfigureautomake

configure: Specify a path to search in for headers AFTER the default paths


To add a path to search in for header files, you can feed an -I argument to configure. However, the added path will then be searched in before the default ones, effectively overriding the default ones in case of duplication. I want a path to “fall back to” when headers are not available in default paths while still using default headers as much as possible. Is there any way to specify a path to search in for headers after the default paths? Or, for the ultimate purpose, is there any other way round? Like

  • Setting the “search order” for paths; or
  • Specifying the additional path with “low priority,” etc.

Solution

  • Using gcc you might be successful using -idirafter. Keep in mind though that configure may modify your search path with -I on its own, for example when it finds a library in a custom location, it might (and probably will) add -I for this location to all subsequent tests and final compilation, which might still include other packages from this new location if they are available there instead of default location.