Linker error with new class for gateway
-
Hi,
I try to extend the gateway with some functionallity. For that I have written some c++ classes that are tested and working and put them in the /core folder.
But when I compile them in the context of MySensors project I get an linker error:./core/MyGatewayTransportMQTTClient.cpp:136: undefined reference to `SmartSleep::init(std::string)'Is there anything I have to consider when I introduce new classes that consist of a SmartSleep.h and SmartSleep.cpp file?
I extend the Class MyGatewayTransportMQTTClient the following way:
#include "SmartSleep.h" ... static SmartSleep ss; ... bool gatewayTransportInit(void) { ss.init("nodes_smartsleep.cfg");The classes look like:
SmartSleep.h class SmartSleep { public: void init(string); SmartSleep.cpp void SmartSleep::init(string filename) { ... } -
Problem solved with a not so nice hack ;)
I moved my additional .h and .cpp files into one of the library folders MySensors\drivers\BCM\ and now the .o file gets compiled and the linker can find the method implementation.
But why does it not work in the /core folder?
-
Ok now I have found the proper place to include the missing .cpp files to generate the .o files.
In the MySensor.h are all necessary .cpp files from the /core folder
#if defined(MY_GATEWAY_LINUX) #include "drivers/Linux/EthernetClient.h" #include "drivers/Linux/EthernetServer.h" #include "drivers/Linux/IPAddress.h" #endif #include "drivers/PubSubClient/PubSubClient.cpp" #include "core/MyGatewayTransportMQTTClient.cpp" #include "core/MySmartSleep.cpp" #include "core/MySleepNode.cpp
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login