Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] 'undefined reference to `QTcpSocket::QTcpSocket(QObject*)'
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 13.5k Views 1 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.
  • E Offline
    E Offline
    endla.ravi
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maciej
        wrote on last edited by
        #3

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

        //edit: oops Volker was first :P

        Earth is a beta site.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          endla.ravi
          wrote on last edited by
          #4

          ThanQ very much,it got solved...

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved