Hello everyone.
Since release of CLI 5.0 (and 5.0.1 has not changed the behavior), I am getting the following errors when building and testing this project I am partaking in.
EDIT: I figured out and fixed a circular dependency problem between libraries in the project, which solved the build issue! The second (testing) issue is still present.
Working solution for the first issue is available in this branch
$ pio run
[…]
Compiling .pio/build/stm32/lib511/debug/debug.o
In file included from lib/hal/circular_buffer.h:19,
from lib/debug/debug.h:19,
from lib/debug/debug.cpp:49:
lib/hal/hal.h:35:10: fatal error: units.h: No such file or directory
[…]
35 | #include “units.h”
| ^~~~~~~~~
compilation terminated.
*** [.pio/build/stm32/lib511/debug/debug.o] Error 1
Note that the exact same project works fine with CLI 4.3.4. Also note that because we are working on safety critical software, we deliberately don’t use external libraries (so it doesn’t risk breaking when an external library auto-updates).
Here are the information I think will be useful, but feel free to ask (or check the github repo) for additional information:
Dependency Graph
|-- core
| |-- hal
| | |-- checksum
| | |-- units
| | |-- debug
| |-- debug
| |-- network_protocol
| | |-- nanopb
| |-- units
| |-- nanopb
| |-- pid
| | |-- units
|-- hal
| |-- checksum
| |-- units
| |-- debug
|-- debug
|-- network_protocol
| |-- nanopb
|-- units
|-- nanopb
|-- pid
| |-- units
|-- checksum
The (somewhat simplified) project tree goes like this:
common generated_libs network_protocol libs checksum units third_party nanopb controller //this is the platformio project lib core debug hal pid platformio src platformio.ini
platformio.ini specifies
lib_dir = lib
lib_ldf_mode = deep+
lib_extra_dirs =
…/common/libs
…/common/generated_libs
…/common/third_party
BTW, when I replace
#include “units.h”
in hal.h with
#include “…/…/…/common/libs/units/units.h”
the project builds properly, which raises the question: how come #include “network_protocol.h” and #include “pb.h” (which is in third_party/nanopb) work if #include “units.h” fails?
Now the second problem, which also started with CLI 5.0: when working on unit tests for this project with googletest library, unit tests of lib/core that require other libraries (e.g lib/debug) yield the following linker error:
Building…
.pio/build/native/lib61e/libcore.a(blower_fsm.o) : In function « DebugVarBase::DebugVarBase(VarType, char const*, char const*, char const*) » :
/data/RespiraWorks/VentilatorSoftware/software/controller/lib/debug/vars.h:47 : undefined reference to « DebugVarBase::var_count »
[… plenty of similar errors]
collect2: error: ld returned 1 exit status
*** [.pio/build/native/program] Error 1
Once again, I have an unsatisfying solution, which is to get rid of our current architecture and put all the files in lib/core.
Any help is immensely appreciated!