Error message I can't find reason

i get the following error while compiling

/Users/mk/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/main.cpp.o:(.text.setup+0x84): undefined reference to `_Z11publishMQTTPKcS0_' /Users/mk/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: .pio/build/esp12e/src/main.cpp.o: in function `setup': main.cpp:(.text.setup+0x16c): undefined reference to `_Z11publishMQTTPKcS0_' collect2: error: ld returned 1 exit status

i can’find the reason, nothing is underlined in my code. Can anyone give me a hint to find out why. I do not have a variable like `Z11publishMQTTPKcS0
regards reiner

It’s C++ code, so the names are mangled, with their types and classes being encoded in the name. gives back

publishMQTT(char const*, char const*)

as a result, so that is the function that it can’t find.

Thank you for quick response and help. So perhaps you can give me a solution. Following the part of the code leading to the prolem

I have in main.cpp

#include "functions.h"
const PROGMEM char* TOPIC = "some text";

char value[5];
publishMQTT(TOPIC, value);

in fuctions.h

void publishMQTT(const char *topic, const char *payload);

in functions.cpp

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "functions.h"
void publishMQTT( char *topic, char *payload)
mqttClient.publish(topic, payload, true);

The reason is, that I have put all WiFi and MQTT stuff in “functions” and separated from normal code. So I have a module I can use in multiple projects. As mqttClient.publish ist not known in main.cpp publishMQTT should pass the parameters to mqttClient.publish

Regards Rainer

Where’s the const in the char* args? Those are differing types compared to what the header declares.