How to specify a path to a specific header file?

I'm looking for a way to tell the #include statement where to look for a specific header file.

For example, if I have library ABC that includes a file called xyz.h, but I also have library HAL with a file called xyz.h. How do I tell the compiler which one to use? I tried unsuccessfully to add a path as part of the name, and I also tried copying the desired libraries to the sketch folder - it worked a little better but still found the other header and tried to use it instead.

Here is an example that doesn't cause too much problems as the header files appear to be identical: Both the Ethernet and Ethernet2 libraries have header files with identical names (such as Dhcp.h) in their folders, and when compiling it points out bitterly that it had to pick one over the other. Sometimes it grabs them from the Ethernet folder, sometimes from the Ethernet2 folder.

So is this something that can be done?

If you use the style #include <Servo.h> it looks in the library folders
If you use the style #include “Servo.h” it looks in the folder that contains your .ino file

You can also use the style #include “/full/path/name/Servo.h” to find a file anywhere on your hard disk

…R

Just to add to Robin’s input,when using the "" for #include the preprocessor first checks your local sketch directory, and if it doesn’t find a match then moves on to check the system paths (the include path list) whereas using the angle brackets <> starts the search directly in system headers (implementation dependent)

I couldn’t find an official explanation for the Arduino IDE of the difference between using <> vs. “”, and the forums had people insisting there was and wasn’t. Further searching showed that officially C does differentiate, but whether or not that is implemented is dependant on the particular compiler, which didn’t help. :roll_eyes:

I had tried moving the files to the sketch directory and using “” instead of <> but still got the multiple file warning when it tried to compile. Maybe one of the header files is using #include <file.h> for the same file.

I will try the path name again as I think I may have tried that with the <> instead of the “”.

Thanks for the help!

A couple of the header files did try to include a file already included and referenced it with <>. After correcting that it compiled fine.

Not to look for the real errors!