Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

"Undefined reference to"



  • Hi !!
    I got a problem on one of my code :)
    I use this line :

    m_module.insert(std::pair<QString, AbstractGUIModule*>("Source Video", new VideoModule(DLTCommSetup::DEFAULT_DLT_ADDRESS_GND, QString().number(DLTCommSetup::DEFAULT_RTSP_PORT), DLTCommSetup::DEFAULT_RTSP_MEDIA, VERBOSE8MODULES, parent())));
    

    I got the error : "Undefined reference to 'DLTCommSetup::DEFAULT_DLT_ADDRESS_GND' "

    in my header DLTCommSetup :

    static constexpr char DEFAULT_ADDRESS_GND[13]="192.168.x.xx"
    

    So it is well defined here, if needed here is my VideoModule constructor :

    VideoModule::VideoModule(QString ip, QString port, QString media, bool verbose, QObject* interface_qml) :
    AbstractGUIModule("Source Video", verbose, interface_qml), m_video_state(VideoState::OFF), m_current_mode(Mode::GROUND), m_video_packet_flag(false), m_media_player("VideoPlayer")
    

    I dont understand where the "undefined reference" comes from :/
    Thanks for help :D



  • It's okey, I found my problem ! I called the wrong module where my function is, that caused (I dont know why) that error
    Qt Magic !
    Thx for your help :)


  • Lifetime Qt Champion

    Hi
    Make sure you don't have cyclic includes.
    That can also give undefined errors.



  • Ichecked and it is okey, any cyclic include in my project :/


  • Lifetime Qt Champion

    Hi,

    Did you declare DEFAULT_ADDRESS_GND as part of your class or is it floating in the header file ?



  • Hey !
    It is in my public part :

    class DLTCommSetup {
    public: 
    DLTCommSetup();
    ....
    ...
    static constexpr char DEFAULT_ADDRESS_GND[13]="192.168.x.xx"
    
    


  • @Chanchan

    I got the error : "Undefined reference to 'DLTCommSetup::DEFAULT_DLT_ADDRESS_GND' "
    static constexpr char DEFAULT_ADDRESS_GND[13]="192.168.x.xx"

    Maybe it's just me not understanding, but how is DEFAULT_ADDRESS_GND "So it is well defined here" supposed to relate to/help/avoid the undefined reference on DLTCommSetup::DEFAULT_DLT_ADDRESS_GND ?


  • Lifetime Qt Champion

    @JonB
    hehe, its more like you have a good eye :)
    Not the same name.



  • Well that's the point ^^
    I change it thank you... but still the same error (I made a copy/paste sooo we're sure it is the same name now). But the problem still here with the same error message :/ (I cleaned up the project and ran qmake before builded it again



  • @Chanchan
    Show the relevant code and the corresponding error message as they are right now.



  • It's okey, I found my problem ! I called the wrong module where my function is, that caused (I dont know why) that error
    Qt Magic !
    Thx for your help :)


Log in to reply