I’m working on an AVR project that does not use Arduino framework, while also trying to manage libraries using PlatformIO on VSCode but it turns out that I can’t. Honestly I feel a bit surprised that this should be a problem.
So here’s my platformio.ini
:
[env:ATmega168P]
platform = atmelavr
board = ATmega168P ; this can be anything; does not matter
lib_deps =
; some randomly chosen lib just to show that lib manager is broken
adafruit/Adafruit MSA301@^1.1.0
adafruit/Adafruit SleepyDog Library@^1.6.4
olikraus/U8g2@^2.35.4
naguissa/uRTCLib@^6.6.1
…then it’s no surprise that .pio/libdeps/ATmega168P
contain these libraries. The problem is these libraries are just sitting there doing nothing: they don’t appear in .vscode/c_cpp_properties.json
so IntelliSense wouldn’t find any header; and code won’t compile because no headers can be found:
"includePath": [
"/Users/45gfg9/Documents/PlatformIO/Projects/avrlibtest/include",
"/Users/45gfg9/Documents/PlatformIO/Projects/avrlibtest/src",
""
]
Suppose src/main.cpp
is:
#include <avr/io.h>
#include <Adafruit_SleepyDog.h> // IntelliSense yells at this line
int main() {
return 0;
}
and you get
Compiling .pio/build/ATmega168P/src/main.o
src/main.cpp:2:10: fatal error: Adafruit_SleepyDog.h: No such file or directory
****************************************************************************
* Looking for Adafruit_SleepyDog.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:Adafruit_SleepyDog.h"
* Web > https://registry.platformio.org/search?q=header:Adafruit_SleepyDog.h
*
****************************************************************************
#include <Adafruit_SleepyDog.h>
^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/ATmega168P/src/main.o] Error 1
…and as soon as framework = arduino
is specified, the problem goes away. Copying library directories from .pio/libdeps
to lib
does not work, either.
Here’s another strange thing I’ve observed, but I’m not very sure about this one. It seems that hand-created header and sources can be discovered normally, but ones that are copied from libdeps
can’t.