Here is the output from my compile:
Detecting libraries used...
C:\Users\bobco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\mega C:\Users\bobco\AppData\Local\Temp\arduino\sketches\6A778FEE61D35F27831FA5BC62F66989\sketch\sketch_jan12b.ino.cpp -o nul
Alternatives for Adafruit_GFX.h: [Adafruit GFX Library@1.11.9]
ResolveLibrary(Adafruit_GFX.h)
-> candidates: [Adafruit GFX Library@1.11.9]
C:\Users\bobco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\mega -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_GFX_Library C:\Users\bobco\AppData\Local\Temp\arduino\sketches\6A778FEE61D35F27831FA5BC62F66989\sketch\sketch_jan12b.ino.cpp -o nul
Alternatives for Adafruit_I2CDevice.h: [Adafruit BusIO@1.14.5]
ResolveLibrary(Adafruit_I2CDevice.h)
-> candidates: [Adafruit BusIO@1.14.5]
C:\Users\bobco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\mega -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_GFX_Library -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_BusIO C:\Users\bobco\AppData\Local\Temp\arduino\sketches\6A778FEE61D35F27831FA5BC62F66989\sketch\sketch_jan12b.ino.cpp -o nul
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
-> candidates: [Wire@1.0]
C:\Users\bobco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\mega -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_GFX_Library -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_BusIO -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src C:\Users\bobco\AppData\Local\Temp\arduino\sketches\6A778FEE61D35F27831FA5BC62F66989\sketch\sketch_jan12b.ino.cpp -o nul
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
-> candidates: [SPI@1.0]
C:\Users\bobco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\mega -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_GFX_Library -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_BusIO -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\bobco\AppData\Local\Temp\arduino\sketches\6A778FEE61D35F27831FA5BC62F66989\sketch\sketch_jan12b.ino.cpp -o nul
Alternatives for Adafruit_ILI9341.h: [Adafruit ILI9341@1.6.0]
ResolveLibrary(Adafruit_ILI9341.h)
-> candidates: [Adafruit ILI9341@1.6.0]
C:\Users\bobco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\mega -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_GFX_Library -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_BusIO -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src -IC:\Users\bobco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src -Ic:\Users\bobco\OneDrive\Documents\Arduino\libraries\Adafruit_ILI9341 C:\Users\bobco\AppData\Local\Temp\arduino\sketches\6A778FEE61D35F27831FA5BC62F66989\sketch\sketch_jan12b.ino.cpp -o nul
Alternatives for EEPROM.h: [EEPROM@2.0]
ResolveLibrary(EEPROM.h)
-> candidates: [EEPROM@2.0]
This is the "library detection" phase. From observation the process is :
- Compile the sketch without any library paths using -E (preprocess only) option.
- Examine the compiler output for the first unresolved #include.
- Look for the included name in the list of known libraries.
- If the file is not found, output the error message
- If the file is found, goto 1 but add the library path to the compile command.
- If there are no unresolved #includes, then detection is finished. The list of resolved library paths is used to subsequently compiler the sketch.
This process resolves all the includes in the sketch, as well as any nested includes.
In my example, you can see this progress as expected through the sketch. But your case, it seems to go wrong straight off the bat. It should be looking for Adafruit_GFX.h, but instead resolves Adafruit_ILI9341.h :
Alternatives for Adafruit_ILI9341.h: [Adafruit ILI9341@1.6.0]
ResolveLibrary(Adafruit_ILI9341.h)
-> candidates: [Adafruit ILI9341@1.6.0]
which is not the library it was looking for, it then outputs the error which comes from the compiler "F:\Documents\Arduino\PreProcesorBugTest_V3\PreProcesorBugTest_V3.ino:59:10: fatal error: Adafruit_GFX.h: No such file or directory"
However, it goes on to repeat the compiler with the path to Adafruit_ILI9341.h added, and resolves that library again, before giving up.
So it appears the library detection is getting confused about which library it is trying to resolve.
For info, the code that does the library detection is in arduino-cli/internal/arduino/builder/internal/detector/detector.go at master ยท arduino/arduino-cli ยท GitHub. I don't get a very warm and fuzzy feeling reading the code; there are many TODOs. Some seem quite fundamental :
// TODO understand if we have to do a deepcopy
That seems a bit of "fingers crossed and hope it works" kinda thing 