Hi,
I have problem with project compilation using library with nested directory struture.
Library I used and which causes problem is PCAL955x - The PCAL9555, PCAL9554 series is a low-voltage 16… | Mbed which has this structure after imported to PIO:
.piolibdeps\PCAL955x\PCAL9554\PCAL9554.cpp
.piolibdeps\PCAL955x\PCAL9554\PCAL9554.h
.piolibdeps\PCAL955x\PCAL9555\PCAL9555.cpp
.piolibdeps\PCAL955x\PCAL9555\PCAL9555.h
.piolibdeps\PCAL955x\base_classes\PCAL955x.cpp
.piolibdeps\PCAL955x\base_classes\PCAL955x.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\CompGpioExp.cpp
.piolibdeps\PCAL955x\base_classes\CompGpioExp\CompGpioExp.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\CompGpioExpAPI.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioBus\GpioBusIn.cpp
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioBus\GpioBusIn.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioBus\GpioBusInOut.cpp
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioBus\GpioBusInOut.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioBus\GpioBusOut.cpp
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioBus\GpioBusOut.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioDigital\GpioDigitalIn.cpp
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioDigital\GpioDigitalIn.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioDigital\GpioDigitalInOut.cpp
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioDigital\GpioDigitalInOut.h
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioDigital\GpioDigitalOut.cpp
.piolibdeps\PCAL955x\base_classes\CompGpioExp\GpioDigital\GpioDigitalOut.h
Collected 9 compatible libraries
Looking for dependencies...
Project does not have dependencies
Compiling .pioenvs\nucleo_l476rg\src\main.o
src\main.cpp:2:22: fatal error: PCAL9554.h: No such file or directory
#include "PCAL9554.h"
^
compilation terminated.
*** [.pioenvs\nucleo_l476rg\src\main.o] Error 1
[ERROR] Took 4.12 seconds
It looks like it has some issue with library with nested directory structure to find given file. PIO also reports no dependencies.
If I change #include line like this #include "PCAL9554/PCAL9554.h"
compiler finds file PCAL9554.h but other references/includes inside library still not work. Compiler gives:
Looking for dependencies...
Library Dependency Graph
|-- <PCAL955x>
Compiling .pioenvs\nucleo_l476rg\src\main.o
Compiling .pioenvs\nucleo_l476rg\lib\PCAL955x\PCAL9554\PCAL9554.o
Compiling .pioenvs\nucleo_l476rg\lib\PCAL955x\PCAL9555\PCAL9555.o
Compiling .pioenvs\nucleo_l476rg\lib\PCAL955x\base_classes\CompGpioExp\CompGpioExp.o
In file included from src\main.cpp:2:0:
.piolibdeps\PCAL955x/PCAL9554/PCAL9554.h:21:25: fatal error: PCAL955x.h: No such file or directory
#include "PCAL955x.h"
^
compilation terminated.
*** [.pioenvs\nucleo_l476rg\src\main.o] Error 1
In file included from .piolibdeps\PCAL955x\PCAL9554\PCAL9554.cpp:2:0:
.piolibdeps\PCAL955x\PCAL9554\PCAL9554.h:21:25: fatal error: PCAL955x.h: No such file or directory
#include "PCAL955x.h"
^
compilation terminated.
*** [.pioenvs\nucleo_l476rg\lib\PCAL955x\PCAL9554\PCAL9554.o] Error 1
In file included from .piolibdeps\PCAL955x\PCAL9555\PCAL9555.cpp:2:0:
.piolibdeps\PCAL955x\PCAL9555\PCAL9555.h:21:25: fatal error: PCAL955x.h: No such file or directory
#include "PCAL955x.h"
^
compilation terminated.
*** [.pioenvs\nucleo_l476rg\lib\PCAL955x\PCAL9555\PCAL9555.o] Error 1
[ERROR] Took 4.55 seconds
What would be correct way using such library with nested directory structure?
Nevertheless, I was wondering if there is some simpler way instead of listing all subdirectories in library dir. E.g. some option to tell compiler to look recursively in given directory.
but linker is still having problems to link main code with library:
Linking .pioenvs\nucleo_l476rg\firmware.elf
.pioenvs/nucleo_l476rg/src/main.o: In function `main':
main.cpp:(.text.startup.main+0x6): undefined reference to `PCAL955x::configure(int)'
main.cpp:(.text.startup.main+0x10): undefined reference to `PCAL955x::write(int)'
.pioenvs/nucleo_l476rg/src/main.o: In function `_GLOBAL__sub_I_i2c_gpio':
main.cpp:(.text.startup._GLOBAL__sub_I_i2c_gpio+0xc): undefined reference to `PCAL9554::PCAL9554(PinName, PinName, char)'
main.cpp:(.text.startup._GLOBAL__sub_I_i2c_gpio+0x24): undefined reference to `PCAL9554::~PCAL9554()'
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\nucleo_l476rg\firmware.elf] Error 1
[ERROR] Took 4.51 seconds
From co,piler log it looks like PCAL955x library is not compiled even it is in platformio.ini:
PlatformIO Library Dependecy Finder ignores global envrinmoment while find depenpdent candidates. You should configure environment directly from library.json. Just create this file, please to libary folder, fill name and version field, declare custom build option and all should work.
Hello,
apologies for reviving this topic, but I’m running into the same exact problem. I placed a very large library in /lib, with many subfolders, and I can’t find the correct way to make the compiler look recursively using library.json.
The link to the post I’m replying is now pointing at the library.json docs, which are comprehensive, but I can’t find the specific example. I tried writing the following library.json:
… and variations of it, but it did not work. If I manually add folders in platformio.ini as build_flags -I, then it starts to see them - but it’s absolutely unfeasible for me to do so, there’s dozens of folders. Would you be able to help me?