More nested libraries & compilation issues

Hi Community,

I’m porting my private arduino library into platform io and have been running into some issues with directory structure.

I’ve organized my libraries files by function - device classes, system classes, types, data, etc. The structure looks something like this:

lib/MyLib/mylib.h
lib/MyLib/device/mylib_device.h
lib/MyLib/system/mylib_system.h
lib/MyLib/system/types/mylib_types.h
lib/MyLib/system/data/mylib_data.h

I keep getting compiler errors for Undefined Symbols, and looking at the archive MyLib.a, the file size is almost nothing. Apparently my source files aren’t compiling properly.

I’ve tried importing <system/mylib_system.h> and <device/mylib_device.h> and the other headers into my main.cpp source file, AND created direct calls to some of the functions of that library within my main.cpp, but still with the Undefined Symbols.

I duplicated the project moved everything into a flat directory structure, which compiles fine. But ideally I’d love to keep things structured as I have in the past.

Has anyone tackled this yet?

This is a matter of appropriate include directives during compilation. You can modify/add build flags in project configuration in platformio.ini file.

Turns out library v1.5 compatibility solved the issue as seen here: PIO does not compile all included library classes which leads to linker errors

1 Like