Installed Library not found when included?

I’m quite new to PlatformIO and VSCode, although have quite a bit of experience with coding. I am however stumped as to why VSCode seems to think my libraries do not exist.
My code works fine with the IDE, so its just a PlatformIO/VSCode setup issue.

I’ve setup a Wemos D1 Mini project with my ini file looking like so:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino

The 2 libraries that are giving me errors are FirebaseESP8266.h and SSD1306Wire.h

#include <Arduino.h>
#include "FirebaseESP8266.h"
#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include <Servo.h>
#include "SSD1306Wire.h"

For Firebase, I have gone to PIO Home and installed the lib to my project. Is there anything more I need to do here, or should this just be working?

If I try to compile it, it says src\main.cpp:2:29: fatal error: FirebaseESP8266.h: No such file or directory

Check your platformio.ini, and add

lib_deps =
   Firebase ESP8266 Client
   ESP8266_SSD1306

to it if not present, assuming I got the right libraries. It seems that installing a library to a project is currently not working properly.

1 Like

Ah thanks. That’s done it.

I assume that when you install a library to a project, it should automatically add to the lib_deps for you under normal circumstances?

1 Like

That’s what I would have expected to happen. To be honest, I hadn’t tried installing a library via PIO home that way before… I always just put the lib_deps entries in manually. It seems pretty pointless to have the project install option though if it a) doesn’t add to the lib_deps entry and b) doesn’t install the library to the project library cache folder.

1 Like

I’ve just filed a bug report so this can be looked into.

2 Likes

I believe using PIO Home to install project library should just save it to the {projectname}\.pio\libdeps\esp01_1m\{libraryname} folder (if it was working) which will then be automatically included. No need to add it to lib_deps. lib_deps is used to automatically grab the library for you.

1 Like

Yup, that’s what I expected also. I still would have liked it to have an option to add to the lib_deps automatically, as that saves the need to manual install to project if you’ve moved to a different computer, etc, either way, it’s currently not doing the core job of actually installing to the right place! :laughing: :man_facepalming:

Actually you can if you use the terminal to do it;
platformio lib install {library} --save

1 Like

lol… true… thanks for reminding me of that… I forgot that option was added… mainly since I ‘install’ libraries via the lib_deps entry. :slight_smile: I was thinking more along the lines of a checkbox in the GUI for when installing that way.

1 Like

This is a known bug and was fixed in the latest PlatformIO Core 4.2.2-dev version. Please switch to development version of PIO Core => Redirecting... platformio-ide.useDevelopmentPIOCore: true or use lib_deps as described above.

1 Like

Confirmed working with 4.2.2a3

2 Likes

Hi, I’m not sure if it is related, but I try since several days to get the include of a library working.
it works in espidf mode but not in arduino mode:
here the ini file:

[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
lib_deps = davidantliff/esp32-owb@^0.1
pio lib list
Library Storage: XXXXX/Documents/PlatformIO/Projects/test3/.pio/libdeps/wemos_d1_mini32
esp32-owb
=========
ESP32-compatible C component for the Maxim Integrated 1-Wire protocol.

Version: 0.1
Keywords: onewire, 1-wire, bus, sensor, temperature
Compatible frameworks: espidf
Compatible platforms: espressif32
Authors: David Antliff, Chris Morgan

main.cpp:

#include <Arduino.h>
#include "owb.h"
void setup() {
  // put your setup code here, to run once:
}
void loop() {
  // put your main code here, to run repeatedly:
}
Processing wemos_d1_mini32 (platform: espressif32; board: wemos_d1_mini32; framework: arduino)
-----------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wemos_d1_mini32.html
PLATFORM: Espressif 32 (3.1.0) > WeMos D1 MINI ESP32
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.10005.210308 (1.0.5) 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 31 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/wemos_d1_mini32/src/main.cpp.o
Compiling .pio/build/wemos_d1_mini32/FrameworkArduino/Print.cpp.o
Compiling .pio/build/wemos_d1_mini32/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/wemos_d1_mini32/FrameworkArduino/StreamString.cpp.o
src/main.cpp:3:17: fatal error: owb.h: No such file or directory

The library declares only compatibiility with the ESPIDF framework.

Since you’re trying to use it with framework = arduino, PlatformIO rejects it as incompatible.

You can try to ignore the incompatibility by setting lib_compat_mode = off in the platformio.ini, but this is not guranteed to work if the code is truly incompatible especially if it’s written against an ESP-IDF version that is different than the one used in Arduino-ESP32.

oh shit, many thanks to Max.
lib_compat_mode = off does it.

that shows me on which level I’m working …script kid.
may be I should say goodby to arduino mode.

would be great to get a pio dude mode :wink: