PlatformIO Community

Compile with plus cannot fing SPI.h lib_ldf_mode = chain+

Hi,

I am new to PlatformIO, but I suspect a bug. However, easy to reproduce
Install library U8g2, for Platform nordicnrf51 Framework Arduino
Compile example HelloWorld from U8g2, compiles ok
Dependency Graph
|-- <'U8g2> v2.22.6
| |-- <'Wire> v1.0
| |-- <'SPI> v1.0
|-- <'SPI> v1.0

SUCCESS
but when I add lib_ldf_mode = chain+ or lib_ldf_mode = deep+
Dependency Graph
|-- <'U8g2> v2.22.6
…platformio\lib\U8g2_ID942\src\U8x8lib.cpp:42:10: fatal error: SPI.h: No such file or directory
ERROR
It works ok with: lib_ldf_mode = chain or lib_ldf_mode = deep
Unfortunately, I need + for a PIN boards definitions
Is there anybady who can fix it, please?

It seems that is our issue. Could you try to add to your main sketch #include <SPI.h> at the top of file?

I did and the problem still exists, I have loaded spi.h into src - problem still exists, then I loaded the file into project lib - problem still exists, then I loaded the file into U8g2 library folder then shows missing wire.h, and so on

sorry to bump this old thread, but the issue is still happening.
I’m using:
Core 3.6.2a2
and what I did was to clone this project: https://github.com/bitluni/MiniGame.git
with this platformio.ini file:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp8266]
platform=espressif8266
framework=arduino
board=d1_mini
lib_deps =
  # Using a library name
  SparkFun Micro OLED Breakout

[platformio]
src_dir=./MiniGame/

and got this error: .piolibdeps/SparkFun Micro OLED Breakout_ID366/src/hardware.cpp:38:17: fatal error: SPI.h: No such file or directory

But including #include <SPI.h> in MiniGame.ino solved the issue.

This error does not happen if I compile it from Arduino IDE.

Add lib_ldf_mode = deep+ to [env:esp8266]:

[env:esp8266]
platform=espressif8266
framework=arduino
board=d1_mini
lib_ldf_mode = deep+
lib_deps =
  # Using a library name
  SparkFun Micro OLED Breakout

[platformio]
src_dir=./MiniGame/

Hmm, that does not work for me.

Having this platformio.ini:
[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
upload_port = /dev/ttyACM1
upload_speed = 115200
monitor_port = /dev/ttyACM1
monitor_speed = 115200
lib_ldf_mode = deep+
lib_deps =
RadioHead
SPFD5408 TFT Library

… but I’m still getting this:

In file included from .piolibdeps/RadioHead_ID124/RHCRC.h:12:0,
from .piolibdeps/RadioHead_ID124/RHCRC.cpp:43:
.piolibdeps/RadioHead_ID124/RadioHead.h:1179:19: fatal error: SPI.h: No such file or directory

The strange thing is: within vscode, if I ctrl-click on the #include <SPI.h> statement the compiler dislikes in RadioHead.h line 1179, I’ll jump into an existing SPI.h in ./packages/framework-arduinoavr/libraries/cores/arduino/SPI/src/SPI.h

So, vscode seems to be smarter than the compiler. Meh!

Seems I found a (at least temporay) solution by adding the dependency in RadioHead’s library.json file.

Do you use PlatformIO IDE? If yes, do you use the latest development version? Please run pio --version in IDE terminal. Also, don’t forget to $ pio update. We had similar issue which was fixed a few days ago.

I have a problem with the same symptoms. A very simple Arduino sketch, no actual code - just setting up the project. I added Adafruit GFX Library (from Github repository, not from PIO repo), and now the project doesn’t compile as the library cannot find SPI.h. If I include it at the top of my main.cpp, the project does compile, but this include is not necessary in Arduino IDE, and I think it wasn’t necessary for PIO a while ago.

Tried the following lib_ldf_mode values:

  • default (no lib_ldf_mode)
  • 2
  • deep
  • chain
  • deep+
  • chain+

None work. I would like to get rid of the #include <SPI.h> if possible.
Windows 10, VS Code, PIO 4.0.0rc4. Compiling for Arduino Due board.

As of 2021 the problem still occur. I use arduino mega 2560 and the arduino framework. Core pio is 5.0.4 and Home is 3.3.1

I have written my own library that has a dependency on mcp2515 library. MCP2515 depends on SPI.h. The issue came suddenly without changes. Can be temporarily solved by including in the main.cpp of the project SPI.h or by adding SPI.h dependency into library.json or by deep+ in platformio.ini

platformio.ini:

[platformio]
lib_dir = ../../common_lib

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
monitor_speed = 115200
lib_extra_dirs =
    ../../common_lib/base_framework
    ../../common_lib/base_libraries
    ../../common_lib/user_application

The problematic lib is in base_framework folder.

pio update:

Updating platformio/contrib-piohome           3.3.1 @ ~3.3.1                     [Up-to-date]
Updating platformio/contrib-pysite            2.38.201019 @ ~2.38.0              [Incompatible 2.39.201019]
Updating platformio/tool-unity                1.20500.200612 @ ~1.20500.0        [Up-to-date]
Updating platformio/tool-scons                4.40001.0 @ ~4.40001.0             [Up-to-date]

Platform Manager
================
Platform atmelavr
--------
Updating platformio/atmelavr                  3.1.0                              [Up-to-date]
Updating platformio/toolchain-atmelavr        1.50400.190710 @ ~1.50400.0        [Up-to-date]
Updating platformio/framework-arduino-avr     5.1.0 @ ~5.1.0                     [Up-to-date]
Updating platformio/tool-avrdude              1.60300.200527 @ ~1.60300.0        [Up-to-date]

Platform ststm32
--------
Updating platformio/ststm32                   11.0.0                             [Up-to-date]
Updating platformio/toolchain-gccarmnoneeabi  1.70201.0 @ >=1.60301.0,<1.80000.0 [Up-to-date]
Updating platformio/framework-arduinoststm32  4.10900.200819 @ ~4.10900.0        [Up-to-date]
Updating platformio/tool-stm32duino           1.0.1 @ ~1.0.1                     [Up-to-date]
Updating platformio/tool-openocd              2.1000.200630 @ ~2.1000.0          [Up-to-date]
Updating platformio/tool-dfuutil              1.9.200310 @ ~1.9.190708           [Up-to-date]


Library Manager
===============
Library Storage: /Users/x/.platformio/lib
Updating TaskScheduler                        3.1.6                              [Updating to 3.2.2]
Library Manager: Installing TaskScheduler @ 3.2.2
Library Manager: TaskScheduler @ 3.2.2 has been installed!

Edit:
After playing around with includes and dependencies the problem resolved the same as appear, just because of no reason. I have now the same state as before the problem. No includes, no dependencies no ldf params.

I suspect that the order of dependency walktrough of ldf has some issue. The spi lib was more far behind as the issue occured. Now SPI lib is again more at the start of ldf process. It is also now one at the only time it was found, back before at the problem it resolved multiple times.