QTcpServer - Fortune example problem
I am trying to run the fortune example (the simple client-server example) on windows but it is not working.
In a TCP viewer I see that a connection was established between server and client however the newConnection signal in the server side is not emmited.
In the client side I added the waitForConnected function but it results in timeout error.
I also checked the state and saw that it is HostLookupState.
In addition, I wrote a different server-client application not using QT and it works! (But I need to use QT)
So what am I doing wrong? Can someone solve the mistery?
Welcome to the forum.
You have to give some more details on your configuration (what windows, compiler, Qt version). Typically the examples are working, but certainly there is never a guarantee. For this specific eample, it is important to know also from where to where your are trying to make connection.
windows xp, working with visual studio c++ 2005 (created a new QT application), QT version: 4.5.2.
I run the server and client on the same computer. I tried localhost and also tried to write the computer ip
the actual Qt version is 4.7.3. So you might want to update to the newest version.
Out of curiosity I have just compiled the network example as is. It happened to be Qt 4.7.0. I did following:
Opened command prompt in vs2005
Started the debug versions of fortuneserver. This provides already your local ip address and supplies also a port. Start fortuneclient. This supplies also local ip address, but you have to input the port. It works.
You might want to do the same with your installation. I have seen that the example code of 4.5.2 is smaller, but I would need to recionfigure my whole setup for comiplation linking 4.5.2. So it could be that it is better to upgrade to recent version.
I see that when I run the example from 'QT->Examples and Demos' it works. So I guess the problem is with the visual studio (compilation or project creation). Any idea?
Do you have "vsaddin":http://developer.qt.nokia.com/wiki/QtVSAddin installed?
Installing vsaddin wil add an entry "Qt" to your menu in visual studio.
There is an option for opening *.pro files. You can do the same from within visual studio then. This generates a visual studio automatically as I remember. So, it would be basis for you to do some comparison and finding the reasons.
[quote author="nnn123" date="1312113054"]I see that when I run the example from 'QT->Examples and Demos' it works. So I guess the problem is with the visual studio (compilation or project creation). Any idea?[/quote]
Did you do the recompilation as I have suggested? Check that you have really recompiled. Otherwise you might see the precomiled version working. This should not be a surprise.
If the recompilation does work, you might have messed something during your trials to setup the project through visual studio.
BTW: It is Qt not QT (QuickTime) ;-)
I have the vsaddin installed however openning the pro file failes with error regarding to visual studio version.
I tried to open visual studio with devenv /useenv but it didn't work.
I didn't recompiled with make command since I don't have the gcc compiler on my computer.
Any other suggestions?
I thought you want to use visual studio for compilation.
Make sure that you have installed the version of Qt libs. If you have already binaries for visual studio 2005 you can use those. If you do not have the binaries yet, the official download is for 2008 only. Those are not compatible as far as I know. So, you have to download the sources "here":http://qt.nokia.com/downloads/windows-cpp-vs2008 . This is the automatic download for the 2008 version, but the second on that page provides the source code. You can compile with vs2005. Follow the guidelines. There is only one stumble stone, which is that the command prompt has to be started from visual studio.
When you have installed that version. You can install and use vsaddin from vs2005.
Alternatively, you may install the whole setup for gcc. Either way is possible. Since you seem to be familar with vs2005, you might want to go that route. However, that is up to you.
Unfortunately, you cannot compile Qt piece by piece and get it to work.
I am sorry I didn't understand your answer.
I want to compile with visual studio 2005.
I have a proper installation of visual studio, Qt, and vsaddin.
Which installation should I change?
If you have a proper installation of Qt with visual studio, you should be able to compile the network example as I did. There is no need to have gcc installed. Your previous reply confused me a little then.
Open the command through visual studio tools.
Go to the example\network directory.
Start qmake and nmake afterwards as I have described above. If your installation is ok, you should be able to do so.
With the recompiled version you should also be able to check out the fortune server/client example. If this runs ok, the open question would be what is different to your initial approach. Either you have changed a part of the example program or the settings you have used are a problem.
qmake works. nmake doesn't work.
Assuming that you have started the command prompt through vs2005 it should work, when all settings are ok.
Therefore make sure that you did go in vs2005 to "tools" and there is an entry starting the command prompt with the vs environment. This is often forgotten, but it is essential. Otherwise nmake will fail.
I think that I have this problem because I work with visual 2005.
Maybe I need to use something else instead of QTCPSertver.
Thank you very much for your help :-)
There should not be a problem!!! I have been able to compiles Qt and all tools and example with every MSVC version since version .NET (2003). Therefore, again make sure you use the VS2005 command promt not just cmd.
I can also only reiterate it is working fine with visual studio 2005. I have tested the other day the recompilation of the fortune server/client with it.
So I really don't know what can it be (and I really want to find it out).
I am sure I use the VS2005 command.
The nmake didn't work. When I look in the internet I saw that the files which are missing are VS2008 files. When I tried to create the vcproj from pro file I got an error relating to the Visual studio version. Because of those two reasons I thought that the problem is VS version.
Is there another way to convert pro file to vcproj?
You should provide the error messages you got.
However, it looks that we are mixing up things.
Here you wrote:
[quote author="nnn123" date="1312177600"]qmake works. nmake doesn't work.[/quote]
This is before any .vproj file. That was your reply on recompilation of the fortune example. This should be a trial with the command prompt started through visual studio. If nmake does not work in the command window opened through visual studio, there is a problem with your visual studio setup.
What is happening when you open the command prompt through visual studio and you simply type nmake?
Please post the messages obtained.
can not open include file stddef.h. no such file or diretory
fatal error U1077 cl return code 0x2
fatal error U1077 make return code 0x2
It is missing a standard header file. So there is something with your environment wrong.
In your command prompt you can run "set include". There you should find the directory where this file is located. This entry is probably missing.
However, in general I would suggest that you repair or reinstall your visual studio including all service packs. Then you should install Qt and vsaddin again.
The problems you have are not Qt related. It just happened to show up with your trials with the fortune server/client example.
I didn't reinstall yet.
I found out that there was an environment variable belong to VS with " at the end
I removed it and now nmake works!
I compiled the server and client with nmake and run the applications. It worked.
I tried to compile it with VS but it is still didn't work.
Do you still think I should reinstall or do you have other idea?
Without knowing where and how you have chanegd the setting, it is not possible to give you a decent advise in that regard.
However, if you like to know my personal opinion, I would reinstall. As long as you do not know how the change happened, you cannot know what else could have been changed. Changing forth and back with all the trials is sometimes more time consuming than starting from scratch with a fresh setup.
I removed from the additional dependencies in the link tab libraries (gui and designer) and it worked.
Thanks again :-)
(gui and designer - Qt libraries)
I see now that it didn't work with those libraries because it was a realese and not debug
Good to know that you have solved your issue.
However, if problem are persistingh, you might want to consider to change to a newer version of Qt.
If your problems solved, please be sure and add [Solved] to the beginning of the title of the thread. Thanks!