bug: strange include failure for /lib code
Forwarding from https://github.com/platformio/platformio-core/issues/4513# following @ivankravets recommendation.
Copy of the issue:
I am hitting a strange include failure for some /lib code in a PlatformIO project (I put nearly all the code in /lib these days because of some habits I grabbed from some projects where I run quite a few unit-tests, which can include code from /lib but not from /src ; if putting most of my code in /lib is an antipattern, sorry, let me know).
To reproduce the exact same setup:
-
install the sparkfun artemis core in v 1.2.3: https://github.com/nigelb/platform-apollo3blue , detailed instructions https://github.com/jerabaul29/OpenMetBuoy-v2021a/blob/main/development_environment/setup_platformio_environment/Instructions.md .
-
set up the repo:
git clone [email protected]:jvoermans/Wind_Input_V1.git
git checkout logger_version_jr-import_issue_sdfat
git submodule init
git submodule update
- try to compile in PlatformIO; I get the log and error:
Executing task: platformio run
Processing SparkFun_RedBoard_Artemis (platform: apollo3blue; board: SparkFun_RedBoard_Artemis; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/apollo3blue/SparkFun_RedBoard_Artemis.html
PLATFORM: Apollo 3 Blue (0.0.2) > SparkFun RedBoard Artemis
HARDWARE: AMA3B1KK 48MHz, 384KB RAM, 960KB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
- framework-arduinoapollo3 @ 1.2.3
- toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 26 compatible libraries
Scanning dependencies...
Dependency Graph
|-- data_manager
|-- config
| |-- SdFat @ 2.2.0
| | |-- SPI @ 1.0
| |-- utils
|-- gnss_manager
| |-- Embedded Template Library - Arduino @ 20.35.5
| |-- config
| | |-- SdFat @ 2.2.0
| | | |-- SPI @ 1.0
| | |-- utils
| |-- kiss_clang_posix_time_utils
| |-- statistical_processing
| | |-- Embedded Template Library - Arduino @ 20.35.5
| | |-- config
| | | |-- SdFat @ 2.2.0
| | | | |-- SPI @ 1.0
| | | |-- utils
| |-- time_manager
| | |-- config
| | | |-- SdFat @ 2.2.0
| | | | |-- SPI @ 1.0
| | | |-- utils
| | |-- kiss_clang_posix_time_utils
| | |-- utils
| |-- watchdog_manager
| | |-- WDT @ 0.1
| |-- Adafruit GPS Library @ 1.7.1
| | |-- SPI @ 1.0
| | |-- Wire @ 1.0
|-- sd_manager
| |-- SdFat @ 2.2.0
| | |-- SPI @ 1.0
| |-- config
| | |-- SdFat @ 2.2.0
| | | |-- SPI @ 1.0
| | |-- utils
| |-- gnss_manager
| | |-- Embedded Template Library - Arduino @ 20.35.5
| | |-- config
| | | |-- SdFat @ 2.2.0
| | | | |-- SPI @ 1.0
| | | |-- utils
| | |-- kiss_clang_posix_time_utils
| | |-- statistical_processing
| | | |-- Embedded Template Library - Arduino @ 20.35.5
| | | |-- config
| | | | |-- SdFat @ 2.2.0
| | | | | |-- SPI @ 1.0
| | | | |-- utils
| | |-- time_manager
| | | |-- config
| | | | |-- SdFat @ 2.2.0
| | | | | |-- SPI @ 1.0
| | | | |-- utils
| | | |-- kiss_clang_posix_time_utils
| | | |-- utils
| | |-- watchdog_manager
| | | |-- WDT @ 0.1
| | |-- Adafruit GPS Library @ 1.7.1
| | | |-- SPI @ 1.0
| | | |-- Wire @ 1.0
| |-- watchdog_manager
| | |-- WDT @ 0.1
| |-- SPI @ 1.0
|-- sleep_manager
| |-- config
| | |-- SdFat @ 2.2.0
| | | |-- SPI @ 1.0
| | |-- utils
| |-- kiss_clang_posix_time_utils
| |-- time_manager
| | |-- config
| | | |-- SdFat @ 2.2.0
| | | | |-- SPI @ 1.0
| | | |-- utils
| | |-- kiss_clang_posix_time_utils
| | |-- utils
| |-- watchdog_manager
| | |-- WDT @ 0.1
|-- time_manager
| |-- config
| | |-- SdFat @ 2.2.0
| | | |-- SPI @ 1.0
| | |-- utils
| |-- kiss_clang_posix_time_utils
| |-- utils
|-- watchdog_manager
| |-- WDT @ 0.1
Building in release mode
Compiling .pio/build/SparkFun_RedBoard_Artemis/src/main.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/lib8b0/SPI/SPI.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatDbg.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatFile.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatFilePrint.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatFileWrite.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatFormatter.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatName.cpp.o
Archiving .pio/build/SparkFun_RedBoard_Artemis/lib8b0/libSPI.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/lib8b0/libSPI.a
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatPartition.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/ExFatLib/ExFatVolume.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatDbg.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatFile.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatFileLFN.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatFilePrint.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatFileSFN.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatFormatter.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatName.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatPartition.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FatLib/FatVolume.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FreeStack.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FsLib/FsFile.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FsLib/FsNew.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/FsLib/FsVolume.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/MinimumSerial.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SdCard/SdCardInfo.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SdCard/SdSpiCard.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SdCard/SdioTeensy.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiArtemis.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiChipSelect.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiDue.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiESP.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiParticle.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiSTM32.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiSTM32Core.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/SpiDriver/SdSpiTeensy3.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/FmtNumber.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/FsCache.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/FsDateTime.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/FsName.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/FsStructs.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/FsUtf.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/PrintBasic.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/common/upcase.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/iostream/StdioStream.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/iostream/StreamBaseClass.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/iostream/istream.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/liba08/SdFat/iostream/ostream.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/lib2db/utils/print_utils.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/lib092/config/firmware_configuration.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/lib092/config/user_configuration.cpp.o
In file included from lib/utils/print_utils.h:8,
from lib/utils/print_utils.cpp:1:
lib/config/firmware_configuration.h:4:10: fatal error: SdFat.h: No such file or directory
***************************************************************
* Looking for SdFat.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:SdFat.h"
* Web > https://registry.platformio.org/search?q=header:SdFat.h
*
***************************************************************
4 | #include "SdFat.h"
| ^~~~~~~~~
compilation terminated.
*** [.pio/build/SparkFun_RedBoard_Artemis/lib2db/utils/print_utils.cpp.o] Error 1
==================================================================================================== [FAILED] Took 14.62 seconds ====================================================================================================
* The terminal process "platformio 'run'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
Now what I really cannot understand is that the error is that seems to break compilation is:
lib/config/firmware_configuration.h:4:10: fatal error: SdFat.h: No such file or directory
But the SdFat.h file does is present, in its own lib folder as a submodule, is recognized by the dependency checker built in PlatformIO, etc. Actually, just uncommenting the line:
https://github.com/jvoermans/Wind_Input_V1/blob/f7e8ae031db1b96a731e147fc247a85a0be974e0/lib/utils/print_utils.h#L7
ie importing SdFat.h directly in the print_utils.h header (note that SdFat.h should already be available in print_utils.h due to importing firmware_configuration.h that itself imports SdFat.h) fixes things, which is weird, as it shows that the compiler actually then knows of where to find SdFat.h
Any idea why the compiler cannot find SdFat.h when trying to build print_utils.cpp in a case and not in the other?
Hi @jerabaul29,
If you run platformio in verbose mode (with the -v flag) you can see the command line that is passed to the compiler. I normally compile a few times without cleaning so that there is less noise in the output and then do a verbose compile. With this you can verify that all of the include paths have been passed to the compiler.
What OS are you compiling on? Does this issue persist when you compile on another OS?
I ask this because last year I ran into a weird #include bug where including one of my project headers would cause the Arduino core compile to fail with all kinds of strange errors, but only on Windows.
I moved the include to another file and the error went away. Very strange.
Hi @jerabaul29,
Just wondering how you went with this? If you have a small example project, with the bug, that I can play with I may have some luck narrowing down the issue.
Nigel