I’ve searched the documentation and haven’t really been able to find a solution. I have a private library that contains multiple header and source files. For example, my project structure looks something like this:
EmbeddedProject
├ lib
| └ LibA
| ├ LibA.h
| ├ LibA.cpp
| ├ DataStructure1.h
| ├ DataStructure1.cpp
| ├ DataStructure2.h
| └ DataStructure2.cpp
├ src
| └ EmbeddedProject.ino
└ platformio.ino
With this structure, the linker is complaining, for example, of an undefined reference to DataStructure1::insert(int)
. I could just put everything into a single file, but I feel like that defeats the purpose of even structuring the code into independent libraries to an extent.
My platformio.ino
file is pretty straightforward, I haven’t changed anything from the default generated automatically by PIO except for playing around with the lib_ldf_mode
(I’ve tried changing it to deep
and deep+
). As suggested elsewhere, I have tried to #include
the header files for DataStructure1
and DataStructure2
in the EmbeddedProject.ino
file as well as the LibA.cpp
file, but this did not seem to solve the problem.
So, is there a way to support libraries with multiple cpp files? If so, how? If not, is there a suggested work around? Regardless of the answer, it would be nice to see documentation on the matter.