[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]
3 replies
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.
You must log in to post a reply. Not a member yet? Register here!



