[Solved] 'undefined reference to `QTcpSocket::QTcpSocket(QObject*)'



  • hi,

    I am unable to to use QTcpSocket(same with the case of other QTNetwork modules like QUdpSocket..)

    even if i give
    @QTcpSocket tcp;@

    and run the code,i am getting these compilation errors
    @
    /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::QTcpSocket(QObject*)'

    /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::~QTcpSocket()'

    /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::QTcpSocket(QObject*)'

    /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::~QTcpSocket()'

    error: collect2: ld returned 1 exit status
    @

    And by the way,i have included evrything i should

    ie..

    @
    #include<QTNetwork/QTcpSocket>
    @

    and when i type tcp. I am able to see the snippet.There is no problem while including the class..but only problem while compilation.

    How can i solve this problem

    thanks in advance

    [Edit: fixed code markup, Volker]



  • This is a linker error and caused by QtNetwork lib not being linked to your program.

    Did you add

    @
    QT += network
    @

    to your .pro file? This should make your linker error go away.



  • Have you updated your .pro file with:
    @
    QT += network
    @?

    //edit: oops Volker was first :P



  • ThanQ very much,it got solved...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.