Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Linker error with new class for gateway

Linker error with new class for gateway

Scheduled Pinned Locked Moved Development
3 Posts 1 Posters 868 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    strangeoptics
    wrote on last edited by strangeoptics
    #1

    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) {
       ...
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      strangeoptics
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        strangeoptics
        wrote on last edited by
        #3

        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
        
        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        13

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular