Error messages while trying to add libraries to platformio.ini

Im trying to switch from the arduino IDE to the PlatformIO extension for Visual Studio Code, but im having issues with libraries. I believe ive found all the libraries i have listed in my program, added them to the “platformio.ini” file but im getting errors related to them. Ive created a new project file and was going to make a simple example to upload but after adding the code to platformio.ini i decided to see if i still get an error and i am, hence why its a bare main.cpp.

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:megaatmega2560]

platform = atmelavr

board = megaatmega2560

framework = arduino

lib_deps=

  adafruit/Adafruit HX8357 Library @ ^1.1.10

  adafruit/MAX6675 library @ ^1.1.0

  adafruit/Adafruit GFX Library @ ^1.10.4

  adafruit/Adafruit BusIO @ ^1.7.2

This is the main.cpp. I havent actually requested to include the libraries yet

#include <Arduino.h>

void setup() {

  // put your setup code here, to run once:

}

void loop() {

  // put your main code here, to run repeatedly:

}

This is the error message im getting in the terminal

Terminal will be reused by tasks, press any key to close it.
> Executing task in folder Test: C:\Users\mannf\.platformio\penv\Scripts\pio.exe run <

Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/megaatmega2560.html
PLATFORM: Atmel AVR (3.1.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing adafruit/Adafruit HX8357 Library @ ^1.1.10
Library Manager: Adafruit HX8357 Library @ 1.1.10 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing Adafruit STMPE610
Library Manager: Adafruit STMPE610 @ 1.1.2 has been installed!
Library Manager: Installing Adafruit GFX Library
Library Manager: Adafruit GFX Library @ 1.10.4 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing Adafruit BusIO
Library Manager: Adafruit BusIO @ 1.7.2 has been installed!
Library Manager: Installing Adafruit TouchScreen
Library Manager: Adafruit TouchScreen @ 1.1.1 has been installed!
Library Manager: Installing SD
Library Manager: Warning! More than one package has been found by SD requirements:
 - adafruit/SD @ 0.0.0-alpha+sha.041f788250
 - arduino-libraries/SD @ 1.2.4
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: SD @ 0.0.0-alpha+sha.041f788250 has been installed!
Library Manager: Installing adafruit/MAX6675 library @ ^1.1.0
Library Manager: MAX6675 library @ 1.1.0 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing LiquidCrystal
Library Manager: Warning! More than one package has been found by LiquidCrystal requirements:
 - bitbucket-fmalpartida/LiquidCrystal @ 1.5.0
 - arduino-libraries/LiquidCrystal @ 1.0.7
Library Manager: Please specify detailed REQUIREMENTS using package owner and version (showed above) to avoid name conflicts
Library Manager: LiquidCrystal @ 1.5.0 has been installed!
Library Manager: Adafruit GFX Library @ 1.10.4 is already installed
Library Manager: Adafruit BusIO @ 1.7.2 is already installed
Found 13 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit HX8357 Library> 1.1.10
|   |-- <Adafruit GFX Library> 1.10.4
|   |   |-- <Adafruit BusIO> 1.7.2
|-- <MAX6675 library> 1.1.0
|-- <Adafruit GFX Library> 1.10.4
|   |-- <Adafruit BusIO> 1.7.2
|-- <Adafruit BusIO> 1.7.2
Building in release mode
Compiling .pio\build\megaatmega2560\src\main.cpp.o
Compiling .pio\build\megaatmega2560\lib187\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\megaatmega2560\lib187\Adafruit BusIO\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\megaatmega2560\lib187\Adafruit BusIO\Adafruit_SPIDevice.cpp.o
Compiling .pio\build\megaatmega2560\libb95\Adafruit GFX Library\Adafruit_GFX.cpp.o
Compiling .pio\build\megaatmega2560\libb95\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
Compiling .pio\build\megaatmega2560\libb95\Adafruit GFX Library\Adafruit_SPITFT.cpp.o
In file included from .pio\libdeps\megaatmega2560\Adafruit BusIO/Adafruit_BusIO_Register.h:1:0,
                 from .pio\libdeps\megaatmega2560\Adafruit BusIO\Adafruit_BusIO_Register.cpp:1:
.pio\libdeps\megaatmega2560\Adafruit BusIO/Adafruit_I2CDevice.h:1:18: fatal error: Wire.h: No such file or directory

**************************************************************
* Looking for Wire.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Wire.h"
* Web  > https://platformio.org/lib/search?query=header:Wire.h
*
**************************************************************

compilation terminated.
In file included from .pio\libdeps\megaatmega2560\Adafruit BusIO\Adafruit_SPIDevice.cpp:1:0:
Compiling .pio\build\megaatmega2560\libb95\Adafruit GFX Library\glcdfont.c.o
.pio\libdeps\megaatmega2560\Adafruit BusIO/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

compilation terminated.
In file included from .pio\libdeps\megaatmega2560\Adafruit BusIO\Adafruit_I2CDevice.cpp:1:0:
.pio\libdeps\megaatmega2560\Adafruit BusIO/Adafruit_I2CDevice.h:1:18: fatal error: Wire.h: No such file or directory

**************************************************************
* Looking for Wire.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Wire.h"
* Web  > https://platformio.org/lib/search?query=header:Wire.h
*
**************************************************************

compilation terminated.
*** [.pio\build\megaatmega2560\lib187\Adafruit BusIO\Adafruit_SPIDevice.cpp.o] Error 1
*** [.pio\build\megaatmega2560\lib187\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o] Error 1
*** [.pio\build\megaatmega2560\lib187\Adafruit BusIO\Adafruit_I2CDevice.cpp.o] Error 1
In file included from .pio\libdeps\megaatmega2560\Adafruit GFX Library\Adafruit_GrayOLED.h:30:0,
                 from .pio\libdeps\megaatmega2560\Adafruit GFX Library\Adafruit_GrayOLED.cpp:20:
.pio\libdeps\megaatmega2560\Adafruit BusIO/Adafruit_I2CDevice.h:1:18: fatal error: Wire.h: No such file or directory

**************************************************************
* Looking for Wire.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Wire.h"
* Web  > https://platformio.org/lib/search?query=header:Wire.h
*
**************************************************************

compilation terminated.
*** [.pio\build\megaatmega2560\libb95\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o] Error 1
In file included from .pio\libdeps\megaatmega2560\Adafruit GFX Library\Adafruit_SPITFT.cpp:36:0:
.pio\libdeps\megaatmega2560\Adafruit GFX Library\Adafruit_SPITFT.h:26:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

compilation terminated.
*** [.pio\build\megaatmega2560\libb95\Adafruit GFX Library\Adafruit_SPITFT.cpp.o] Error 1
============================================================================================== [FAILED] Took 10.44 seconds ==============================================================================================
The terminal process "C:\Users\mannf\.platformio\penv\Scripts\pio.exe 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Im a little confused with the above. I found the following post

Wire.h not found, platformio latest version

which refers to one of the libraries im having issues with “Wire.h” but when i wrote “Wire” in the platformio.ini file as suggested in the post its still not removing the error. I also cant find one file called “Wire” when i search in the libraries.

Wire is a builtin library. PlatformIO’s library dependency finder (LDF) needs a little help here. You need to #include <Wire.h> in your main.cpp file after Arduino.

It would probably also fix the error as soon as you include one of the other libraries which depend on Wire.

Another thing would be to set the LDF mode to a more aggressive setting, like deep+ or chain+, but this costs time and the first solution should work.

1 Like

You’re a legend, thank you very much :slight_smile: