December 20, 2010

endla.ravi endla.ravi
Lab Rat
17 posts

[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

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*)'
  2.  
  3. /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::~QTcpSocket()'
  4.  
  5. /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::QTcpSocket(QObject*)'
  6.  
  7. /home/ravi/Messenger-build-desktop/../Messenger/messengerwindow.cpp:215: error: undefined reference to `QTcpSocket::~QTcpSocket()'
  8.  
  9.  
  10.  error: collect2: ld returned 1 exit status

And by the way,i have included evrything i should

ie..

  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
5428 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
67 posts

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

//edit: oops Volker was first :P

 Signature 

Earth is a beta site.

December 20, 2010

endla.ravi endla.ravi
Lab Rat
17 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!