Can't build after splitting SRC


#1

Hi.I want to make several targets for several similar, but different devices
Idea is to have common source code in /src/common.
Every sub-project will have /src/target with main.cpp and config.h

here is excerpt from my platformio.ini:

[platformio]
src_dir=src/common
lib_dir=lib

[env:power_meter]
platform=espressif8266
board=esp12e
framework=arduino
src_filter=+<../power_meter_and_door_bell>
lib_deps=
  89
  436
  561
  562
...
[env:water_meter]
...
src_filter=+<../water_meter>
...

Now i’m trying to build “Power Meter” target and getting include-error from the library i used (not a particular library, any will fail):

Compiling .pioenvs\power_meter\lib56e\JsonStreamingParser_ID561\JsonListener.cpp.o
Compiling .pioenvs\power_meter\lib56e\JsonStreamingParser_ID561\JsonStreamingParser.cpp.o
In file included from src\power_meter_and_door_bell\main.cpp:46:0:
.piolibdeps\ESP8266_SSD1306_ID562/SSD1306Wire.h:32: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
*
**************************************************************

#include <Wire.h>
^
compilation terminated.
*** [.pioenvs\power_meter\power_meter_and_door_bell\main.cpp.o] Error 1
  1. How can I fix this?
  2. And are there any better/best practice approaches to sub-projects separation?

#2
  1. Please keep src folder as a root for your project.
  2. Add somewhere in the project files #import <Wire.h> or change LDF mode to deep+. See docs