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?
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
-idirafterdirSearch dir for header files, but do it after all directories specified with
-Iand 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--sysrootand-isysroot.
-i* explanations on that page are exhaustive.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.