What is a good way to include the adafruit Wire library for SAMD21 adafruit boards?

I’m trying to compile some code with the Adafruit Dotstar library but got Wire.h not found error. Looking at the compilation flags, I find that the packages/framework-arduino-samd-adafruit/libraries/Wire isn’t getting included.

I fixed it by adding a build flag to the platform.ini file.

build_flags =
    -I"${platformio.packages_dir}/framework-arduino-samd-adafruit/libraries/Wire"

Looking at the build flags, I noticed that by default SPI, Zero_DMA adafruit libraries are automatically included.

arm-none-eabi-g++ -o ".pio/build/adafruit_feather_m0_express/liba57/Adafruit BusIO/Adafruit_I2CDevice.cpp.o" -c -fno-rtti -fno-exceptions -std=gnu++11 -fno-threadsafe-statics -mcpu=cortex-m0plus -mthumb -Os -ffunction-sections -fdata-sections -Wall -nostdlib --param max-inline-insns-single=500 -Wno-expansion-to-defined -DPLATFORMIO=60117 -DARDUINO_SAMD_ZERO -DARDUINO_SAMD_FEATHER_M0 -DARDUINO_SAMD_FEATHER_M0_EXPRESS -DARM_MATH_CM0PLUS -D__SAMD21G18A__ -DARDUINO=10805 -DF_CPU=48000000L -DUSBCON -DUSB_VID=0x239A -DUSB_PID=0x801B "-DUSB_PRODUCT=\"Feather M0 Express\"" -DUSB_MANUFACTURER=\"Adafruit\" -DARDUINO_ARCH_SAMD -DUSB_CONFIG_POWER=100 -DARDUINO_SAMD_ADAFRUIT -DPIO_UNIT_TESTING "-I.pio/libdeps/adafruit_feather_m0_express/Adafruit BusIO" -I/home/loki/.platformio/packages/framework-arduino-samd-adafruit/libraries/SPI -I/home/loki/.platformio/packages/framework-arduino-samd-adafruit/libraries/Adafruit_ZeroDMA -I/home/loki/.platformio/packages/framework-cmsis/CMSIS/Core/Include -I/home/loki/.platformio/packages/framework-cmsis-atmel/CMSIS/Device/ATMEL -I/home/loki/.platformio/packages/framework-arduino-samd-adafruit/cores/arduino -I/home/loki/.platformio/packages/framework-arduino-samd-adafruit/libraries/Adafruit_TinyUSB_Arduino/src/arduino -I/home/loki/.platformio/packages/framework-cmsis/CMSIS/DSP/Include -I/home/loki/.platformio/packages/framework-arduino-samd-adafruit/variants/feather_m0_express ".pio/libdeps/adafruit_feather_m0_express/Adafruit BusIO/Adafruit_I2CDevice.cpp"

I’m quite the beginner to PlatformIO, so I’m trying to figure out how to make it so the remaining libraries (Wire, Servo, USBHost, etc.) are also automatically added.

Are the libraries not automatically added for a good reason? If not, does anyone know what files I need to modify to make it so that these libraries are automatically added when the adafruit_feather_m0_express board is chosen?

If a library can’t find its subdependencies, then the library dependency finder has failed. Still, the LDF can operate in different modes, so you should try them all first. Do not manually include the library via build_flags, because that can lead to the case where the source code for the Wire library is not compiled, because it’s not recognized as included by the LDF. The LDF is at the core here.

Using

lib_ldf_mode = deep+

should be your first try.

1 Like

that worked wonderfully, thanks!

the dependency manager looks interesting, seems like adding the SPI libraries was because of the dependency manager and not because it was hardcoded somewhere like I thought,

thanks for the help