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

Time:09-17

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.

CodePudding user response:

As you stated specifying the path using that flag will add it to the beginning of the include/library path. One possible work-around would be to add your custom library paths to your ld.so.conf file. This article goes over Library path in gcc various commands/environment variables to help you do so.

By default, /etc/ld.so.conf refers to the content of all files in the directory /etc/ld.so.conf.d. You can look into the directory to control the configuration.

CodePudding user response:

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.

  • Related