Own libraries compiled but not linked (apparently)

Help! I don`t know what I am doing wrong…
My project structure:
image

At Build time, LDF detects all dependencies OK:

LDF: Library Dependency Finder ->
LDF Modes: Finder ~ deep+, Compatibility ~ soft
Found 45 compatible libraries
Scanning dependencies…
Dependency Graph
|-- <MQTT> 2.5.0
|-- <ArduinoJson> 6.19.1
|-- <DHT sensor library> 1.4.3
| |-- <Adafruit Unified Sensor> 1.1.4
|-- <Adafruit Unified Sensor> 1.1.4
|-- <OneWire> 2.3.6
|-- <DallasTemperature> 3.9.1
| |-- <OneWire> 2.3.6
|-- <ESP8266WiFi> 1.0
|-- <sensors>
| |-- <ESP8266WiFi> 1.0
| |-- <DHT sensor library> 1.4.3
| | |-- <Adafruit Unified Sensor> 1.1.4
| |-- <OneWire> 2.3.6
| |-- <DallasTemperature> 3.9.1
| | |-- <OneWire> 2.3.6
|-- <Relay>
| |-- <ESP8266WiFi> 1.0
|-- <IoTServer>
| |-- <ESP8266WiFi> 1.0
| |-- <MQTT> 2.5.0
|-- <IoTDevice>
| |-- <ESP8266WiFi> 1.0
| |-- <sensors>
| | |-- <ESP8266WiFi> 1.0
| | |-- <DHT sensor library> 1.4.3
| | | |-- <Adafruit Unified Sensor> 1.1.4
| | |-- <OneWire> 2.3.6
| | |-- <DallasTemperature> 3.9.1
| | | |-- <OneWire> 2.3.6
| |-- <DHT sensor library> 1.4.3
| | |-- <Adafruit Unified Sensor> 1.1.4
| |-- <OneWire> 2.3.6
| |-- <DallasTemperature> 3.9.1
| | |-- <OneWire> 2.3.6
Building in release mode

afterwords, it seems that all own libraries are successfully compled:

Compiling .pio\build\esp01_1m\lib8bb\sensors\TempSensor.cpp.o
Compiling .pio\build\esp01_1m\libb1a\Relay\Relay.cpp.o
Compiling .pio\build\esp01_1m\lib255\IoTServer\IoTServer.cpp.o
Archiving .pio\build\esp01_1m\lib010\libESP8266WiFi.a
Compiling .pio\build\esp01_1m\lib85a\IoTDevice\IoTDevice.cpp.o
Archiving .pio\build\esp01_1m\lib8bb\libsensors.a

However, at linking, the following messages appear:
Linking .pio\build\esp01_1m\firmware.elf
c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/…/lib/gcc/xtensa-lx106-elf/10.3.0/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: .pio\build\esp01_1m\src\main.cpp.o:(.text._Z17senseAndReportAllv+0x18): undefined reference to _ZN9IoTServer12reportMetricE6Stringf' c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\esp01_1m\src\main.cpp.o: in function _Z17senseAndReportAllv’:
main.cpp:(.text._Z17senseAndReportAllv+0x4e): undefined reference to _ZN9IoTServer12reportMetricE6Stringf' c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: main.cpp:(.text._Z17senseAndReportAllv+0x7d): undefined reference to _ZN9IoTServer12reportMetricE6Stringf’
c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/…/lib/gcc/xtensa-lx106-elf/10.3.0/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: main.cpp:(.text._Z17senseAndReportAllv+0x9d): undefined reference to _ZN9IoTServer12reportMetricE6Stringf' c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\esp01_1m\src\main.cpp.o:(.text._Z7connectv+0x30): undefined reference to _ZN9IotDevice2idEv’
c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/…/lib/gcc/xtensa-lx106-elf/10.3.0/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: .pio\build\esp01_1m\src\main.cpp.o:(.text._Z7connectv+0x34): undefined reference
to _ZN9IoTServer7connectEPKcS1_S1_b' c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\esp01_1m\src\main.cpp.o:(.text._Z7connectv+0x38): undefined reference to _ZN9IoTServer9subscribeERK6String’
c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/…/lib/gcc/xtensa-lx106-elf/10.3.0/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: .pio\build\esp01_1m\src\main.cpp.o: in function _Z7connectv': main.cpp:(.text._Z7connectv+0x82): undefined reference to _ZN9IotDevice2idEv’
c:/users/linoprah/.platformio/packages/toolchain-xtensa/bin/…/lib/gcc/xtensa-lx106-elf/10.3.0/…/…/…/…/xtensa-lx106-elf/bin/ld.exe: main.cpp:(.text._Z7connectv+0x9f): undefined reference to `_ZN9IoTServer7connectEPKcS1_S1_b’

What am I missing?
I have tried moving the .cpp and .h files around (src, include, lib) in all possible combinations.
I have tried changing lib_ldf_mode

According to my understanding, the /lib folder content should be processed with no additional config. Am I missing a reference to my libraries? Is wo, where and how should they be referenced?

Thank you in advance!

P.D: as suggested by ** maxgerhardt**, I’ve just uploaded the project to GitHub: GitHub - linoprah/home-iot-platformio-q

Can you upload a minimal version of the project that reproduces the problem to Github?

Uploaded here: GitHub - linoprah/home-iot-platformio-q
Thank you very much!

The implementation style of all your C++ classes is wrong.

Take a look at e.g. lib/IoTServer/IoTServer.cpp, you write

to implement the previously declared function, however, the correct form would be to not do a class IoTServer { /* all function implementations here*/} but

// Constructor
IoTServer::IoTServer(String server, String clientName, Client &net, MQTTClientCallbackSimple callback){
            clientName_=clientName;
            Serial.print("creating IoTServer "+ clientName_ );
            client.begin(server.c_str(), net);
            client.onMessage(callback);
 }

void IoTServer::setName(String name){ clientName_=name; }

etc.

You have C++ problem, not a PlatformIO problem. See e.g.

This exact type of error is present in every of your library cpp files.

1 Like

Thank you maxgerhardt, you are great!

Next time I’ll RTFM before asking…
All workging after cleaning my sh…t.

Once again, thank you!