Hello, i just started using platformIO, and im having some issues with the Library Manager.
First i started using the blink sketch, it worked fine, then i sent some Serial messages, all good… next thing i tried was printing stuff on a small OLED screen SSD1306, for this i installed the library using the library manager Adafruit SSD1306 “by Adafruit” and while the installation went well, as soon as i try to build my project (even without including the library in the sketch) im getting this error:
In file included from .pio\libdeps\nanoatmega328new\Adafruit SSD1306\Adafruit_SSD1306.cpp:53:0:
.pio\libdeps\nanoatmega328new\Adafruit SSD1306\Adafruit_SSD1306.h:39:26: fatal error: Adafruit_GFX.h: No such file or directory
Im not sure whats going on, it just won’t build or work at all. it wold seem that its trying to look for the library in a global folder and not the project itself.
Here is my System info
PS C:\Users\RED\Documents\PlatformIO\Projects\Blink Test> pio system info
-------------------------- ----------------------------------------------------
PlatformIO Core 5.1.1a1
Python 3.7.7-final.0
System Type windows_amd64
Platform Windows-10
File System Encoding utf-8
Locale Encoding cp1252
PlatformIO Core Directory C:\Users\RED\.platformio
PlatformIO Core Executable C:\Users\RED\.platformio\penv\Scripts\platformio.exe
Python Executable c:\users\red\.platformio\penv\scripts\python.exe
Global Libraries 0
Development Platforms 2
Tools & Toolchains 25
-------------------------- ----------------------------------------------------
Hi Ifvideos and welcome.
Yeah, there’s a difference between installing a library for the project and installing it for global usage.
I’d recommend to install most - if not all - libs in project scope to keep concerns separated. You might want to uninstall this lib in the manager and just enter its name under lib_deps = in the platformio.ini; it will auto-download on build. See here for help on lib_deps. It makes sense to specify a lib version (because libs might change over time and if they are not kept backwards-compatible, future builds might fail - although this is unlikely for well-maintained Adafruit stuff).
Hey, thanks for the response. I’ve been importing them to the project, as far as i can see they removed the option to import them globally in the last version or something.
I’ll try adding it to the lib_deps to see how it goes.
“Adafruit GFX Library” is automatically included through SSD1306 but “Adafruit BusIO” not, because the library sits behind a #ifdef .. #include.. #endif barrier and PlatformIO’s LDF does not evaluate that in standard mode. It would okay if you set lib_ldf_mode = deep+ (docs) though.
Yes there’s a second barrier. Even if the folder is there, PlatformIO has to recongize the inclusion of the BusIO library in order to generate the right include flags and compile its source code. Per reason in the first paragraph that needs a quirk. As said, either per lib_deps inclusion and a reference in the main.cpp file or a more aggressive LDF setting.
I’ll have to check this and i’ll get back to you.
Seems like this could be the issue indeed, it would be great if it included it by default but oh well.
If lib_ldf_mode = deep+ would be default (aka, evaluate all C/C++ macros in the deep chain and check whether other header files are included which need to be added in the build process), we would be increasing the compile time drastically for all users (like +3 seconds at the start of every compilation in a maybe 2 second total compilation time for Arduino Uno).
If all libs are specified in lib_deps (even the dependencies which might be behind such a #ifdef wall / check) and the library you want to use is #include-ed in the source code, it will work, and compilation will be fast.
This is just one of these quirks that you have to know in library management and how PlatformIO finds or does not find a needed library .
Thank you so much for helping me take my first steps into this platform
It is hard going from the Arduino IDE into this beast hehe but i bet it would be worth the effort.
Definitely it’s some effort, but the advantages will soon shine through. The GUI frontend is all nice and such and can definitely be worked with, just this instance is a quirk in the PlatformIO library finder. So it’s always good to know what goes on behind the curtains and how to configure the project yourself.
For that, PlatformIO’s documentation is vast and explanative. See docs.platformio.org/. For the library configuration part, this applies.
So, i tried once again to include the library but now i added the folders manually to the lib folder, i followed all the “installation” steps, i got the SSD1306, then Adafruit GFX and gave me the error again so got the Adafruit_BusIO-master from Github and even adding it to the lib folder it just wouldn’t compile.
I finally added the lib_ldf_mode = deep line you suggested before and it compiles without issues. I was expecting this method to work better than the Library manager because thats how it works on the Arduino IDE but apparently its not the Manager but the way Platformio deals with dependencies.