PDA

View Full Version : Please Help, QTcpSocket class use



aash_89
12th July 2010, 19:23
hello, i am new to Qt. i am trying to implement a client server application.



i get error messages for one line of code!!





this is my code.



i have included the <QtNetwork/QTcpSocket> class



code:



QTcpSocket socket;

socket.connectToHost("Local Host",5000);





thats it.



i am using qt creator 4.6, with the option to design UI interface too.



these are the errors



undefined reference to '_imp__ZN10QTcpSocketC1EP7QObject'

similar to the above 10 errors!



please help!!

tbscope
12th July 2010, 19:29
undefined reference to '_imp__ZN10QTcpSocketC1EP7QObject'


That's a linker error. It means that it can't find a certain function or class in the libraries it has access to (or knows about).

Why you get this error is not easy to answer with the explanation you gave. So please post your complete code, including your .pro file and explain exactly how you build your code. Are you using Qt Creator for example?

suslik
12th July 2010, 19:33
Also, please try to load one of Qt Examples with networking such as Fortune Client Example, and just try to build it. Perhaps something wasn't configured properly during your installation of Qt.

aash_89
12th July 2010, 19:48
Thank you for the prompt reply.
I just executed the fortune server client application, it worked perfectly.

Yes i am using Qt creator, i just make an interface, and then go to the source file, type the code and say build, it automatically executes!

i will upload my .pro file

aash_89
13th July 2010, 00:34
In the example(fortune), they include QtNetwork class.

how ever when i do the same, its not possile.

i have to use QtNetwork/QtNetwork.

or even if i need to used QTCPsocket class

i need to say QtNetwork/QTCPsocket

is that the problem?

wysota
13th July 2010, 00:55
Do you have "QT += network" line in your project file?

aash_89
13th July 2010, 04:26
thank you. thats what i was missing! i figured it out a while back! thankx anyway.

now have it working!