SPI.h error, Variable has not been declared

I am using ESP32 board, espressif 32 platform, to do my project.

But, I keep facing this SPI.h library problem which mentioned that the file has error with the variable declaration, as below.

Can someone guide me what should I do with this library error, I have tried to add and change to different libraries, but still not able to solve the problem, keep showing the error, please help me TT

These are the github links that I have included, but the SPI and Adafruit ButIO still showing the error, I have no idea on it…

<< platformio.ini >>

; 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:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
	https://github.com/adafruit/Adafruit_MPL3115A2_Library.git
	https://github.com/PaulStoffregen/SPI.git
	https://github.com/avishorp/TM1637.git
	https://github.com/MrRobotrick/GY-NEO6MV2_GPS_Module.git
    https://github.com/junhuanchen/Esp32-SoftwareSerial.git
    https://github.com/adafruit/Adafruit_BusIO.git
    https://github.com/espressif/arduino-esp32.git
    https://github.com/arduino/ArduinoCore-avr.git

Please do not post file contents as screenshots.
Use preformatted text by enclosing the text in three backticks:

```
your code or file content here
```

Libraries that you include, but which are not compatible with the ESP32 architecture or are even unnecessary:

  • GitHub - PaulStoffregen/SPI: SPI library for Teensy & Arduino IDE:
    Teensy not ESP32!

  • GitHub - arduino/ArduinoCore-avr: The Official Arduino AVR core:
    AVR not ESP32!

  • GitHub - espressif/arduino-esp32: Arduino core for the ESP32
    Totally wrong. Platform and framework is defined by platform and framework setting

On top of all the right things @sivar2311 said, try using this platformio.ini instead.

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
  adafruit/Adafruit MPL3115A2 Library@^2.1.2
  https://github.com/avishorp/TM1637.git
  mikalhart/TinyGPSPlus@^1.0.3
  plerup/EspSoftwareSerial@^8.2.0
  adafruit/Adafruit BusIO@^1.15.0

I’ve removed all unnecessary ones, used more mainstream library for some (e.g. the direct TinyGPSPlus library instead of that old fork, or a newer version of the EspSoftwareSerial), and the PlatformIO Registry with stable versioning instead of git links (if they were registered).

1 Like

@maxgerhardt

Understand, I used to copy and paste all the libraries from the github, until I learned a tutorial YouTube video which guides to add the libraries by clicking the Quick Access, then click Libraries… Really appreciate the opinion and all the guidance. Thanks a lot. <3

@sivar2311

Understand, next time will change to preformatted text instead of screenshot the images.

Ok, I will take notes on those libraries and will be careful and more focusing on deciding the libraries from github.

Thanks for the guidance <3