December 20, 2010

endla.ravi endla.ravi
Lab Rat
6 posts

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



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

even if i give

and run the code,i am getting these compilation errors

  1. /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::QTcpSocket(QObject*)'
  3. /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::~QTcpSocket()'
  5. /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::QTcpSocket(QObject*)'
  7. /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::~QTcpSocket()'
  10.  error: collect2: ld returned 1 exit status

And by the way,i have included evrything i should


  1. #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]

3 replies

December 20, 2010

Volker Volker
Ant Farmer
5331 posts

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

Did you add

  1. QT += network

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

December 20, 2010

maciej maciej
Lab Rat
58 posts

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

//edit: oops Volker was first :P


Earth is a beta site.

December 20, 2010

endla.ravi endla.ravi
Lab Rat
6 posts

ThanQ very much,it got solved…

  ‹‹ How do I get my JS running?      Qt::Key and QKeyEvent issues (on-screen keyboard) ››

You must log in to post a reply. Not a member yet? Register here!