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


#1

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?


#2

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


#3

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


#4

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.


#5

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/

#6

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

#7

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!


#8

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


#9

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.