PDA

View Full Version : Installing Qt 4.7 and to Visual Studio 2008



PatchPaper
4th October 2010, 22:20
I've been trying to get Qt installed and work with Visual Studio 2008 for a while now, to no avail. I would have hoped there would have been a straight forward process for this, but I've not seen one yet, so here's the steps I've done so far.

My computer is windows XP 64bit SP 2 intel Xeon 2.4Ghz with 8GB ram.

I've been using the hello world example from here (http://doc.trolltech.com/3.3/tutorial1-01.html) as my test to see if it's been installed correctly yet.

My single error so far has been:
c:\%documentslocation%\my documents\visual studio 2008\projects\helloworld\helloworld\helloworld.cpp (7) : fatal error C1083: Cannot open include file: 'qapplication.h': No such file or directory

First downloaded: http://qt.nokia.com/downloads/sdk-windows-cpp and installed. Which worked by itself, then a little more digging said I had to install the Qt4 Visual Studio Add-in
http://qt.nokia.com/downloads/visual-studio-add-in
Configuring that had issues with the MinGW and refused to find it.

Ok. Then I found these instructions:
http://ngi-central.blogspot.com/2009/09/building-qt-with-visual-studio.html
So I uninstalled, reinstalled following those steps, deleted the stuff that makes it crash and let it run. It ran all the way up to fatal error U1077 which from here:
http://msdn.microsoft.com/en-us/library/dt309377%28VS.71%29.aspx
Sounds like it was just trying to close.
And also set the Path var to include c:\Qt\2010.5\bin\

Went back to configure the Add-in and it still complained that there was minGW installed. Time for some more digging....

Then I found a post (which i've closed already) stating that that this version of Qt needed to be installed instead: http://qt.nokia.com/downloads/windows-cpp-vs2008

So installed that. And then the Qt Add-in automatically found C:\Qt\4.7.0\ folder.
Still no dice.

A little more found me here: http://sector.ynet.sk/qt4-tutorial/preparations.html

So now I have the QTDIR var set to c:\Qt\4.7.0\ and c:\Qt\4.7.0\bin

All this time I still get the original error stated above.

Is QT really this hard to install or have I hit the unlucky streak?

Help please, thanks.

squidge
4th October 2010, 22:36
It's usually easier to start with Qt Creator, at least at the beginning.

This is how I started:
o Create project in Qt Creator. Make it do something (open a window, whatever)
o Install the pre-compiled VS2008 version of the Qt libs in a different dir, so I now have both MinGW as c:\qt\MinGW and VS as c:\qt\VS08
o Install the Qt Plugin for VS2008
o Tell the plugin to load the project (.pro) file created by Qt Creator in the first step
o Clicked "rebuild" and it spat out a working executable
o Modified from there

Don't know why, but I've never tried to create a Qt application in VS08 from scratch.

PatchPaper
4th October 2010, 23:04
Thanks, that works.
Seems rather round about way though. I come from python and pyqt4, and the first thing I learned with pyqt4, was how to build a ui from scratch. Seemed like the simplest way to start with Qt.

squidge
5th October 2010, 07:47
It would probably work straight away if you knew what to use for the default settings (search paths, etc), but rather than remembering them, it's far easier to just import a known working project.

marcvanriet
5th October 2010, 11:46
Hi,

If you're not bound to Visual Studio, I would advise to just stay with QtCreator.

Maybe you are used to Working with Visual Studio, and it is your favourite editor. In that case I understand that you would want to stick with VS. But otherwise there is no reason to use VS. QtCreator is a great environment for developing Qt applications.

Of course you can still use the Microsoft compiler (it is said to generate slightly better code than MingW).

Best regards,
Marc

squidge
5th October 2010, 13:35
I use VS2008 for a few reasons:

Libraries I've already written in VS2008 that I don't want to port to MinGW
I think VS2008 has a better debugger
Compiled code is smaller and seems to be better optimised
Visual Assist for code completion

marcvanriet
5th October 2010, 15:19
Libraries I've already written in VS2008 that I don't want to port to MinGW
Compiled code is smaller and seems to be better optimised

No, no, I didn't suggest you to use MingW, but to use the VS compiler/linker with QtCreator. There are two precompiled packages for Qt on Windows : 1 for MingW and 1 for VS.


I think VS2008 has a better debugger
OK, this is the one thing that working 'natively' in the VS environment may be better in.


Visual Assist for code completion
Code completion in QtCreator is also very good and supports all Qt specialties (like signal and slot names).

But hey, I believe everyone should use the environment they prefer, so... peace man :) :)

PatchPaper
5th October 2010, 22:07
My current preferred is Python and PyQt4 ;)

I feel the need to branch over to C++, so I'm learning Qt and C++ side of things. I didn't know you could program straight into the Creator either. I've run through one of the examples from the help: 'Creating a Qt C++ Application' and when compiling it, it throws this error at me:

'cl' is not recognized as an internal or external command,
operable program or batch file.
command failed with exit code 9009
'cl' is not recognized as an internal or external command,
operable program or batch file.
command failed with exit code 9009
'cl' is not recognized as an internal or external command,
operable program or batch file.
command failed with exit code 9009
'cl' is not recognized as an internal or external command,
operable program or batch file.
command failed with exit code 9009
jom 0.9.4 - empower your cores
command failed with exit code 2
The process "C:/Qt/2010.05/bin/jom.exe" exited with code %2.
Error while building project TextFinder (target: Desktop)
When executing build step 'Make'

It compiles fine from the visual studio when I follow the steps listed above.

NatLWalker
6th October 2010, 08:49
Install the VS2008 Binary Package then install the VS2008 Plugin. It should work find unless you did something wrong, but it's hard to do anything wrong when all you do is run the setup program. Installing one after the other, the plugin detected my Qt installation automatically.

IRT the Visual Studio vs. Qt Creator stuff. There is no comparison between Qt Creator and Visual Studio. Visual Studio does almost everything better. From Editor to Project Manger to a fully integrated Help System (C++ Libraries + Qt stuff).

Visual Studio generates faster and smaller binaries than MinGW.

And "slightly" is quite a subjective term. They are factorably so, and Visual Studio will outperform pretty much any other compiler on Windows barring maybe Intel's compiler in some scenarios (and usually on Intel's processors) because Microsoft invests significant resources in the toolchain used to build their OS and software products (including their mobile products, like Windows Phone 7, etc.).

squidge
6th October 2010, 09:38
Code completion in QtCreator is also very good and supports all Qt specialties (like signal and slot names).
I totally agree. Qt Creator is also free compared to the $249 that Visual Assist costs, plus you need to purchase the Visual Studio environment as the plugin doesn't work with the free editions.

PatchPaper
6th October 2010, 18:25
That's the error that the QTCreator throws me when I try to compile in there, when compiling in visual studio, it found everything and the debug compile works. That just worked.

Though it's kinda annoying to have to go over to visual studio every time to compile the window to see the changes, instead of it running in the Creator, due to that jom.exe error.

marcvanriet
6th October 2010, 20:45
Hi,

cl is the linker from visual studio. Strange that it is not found. When I installed the Qt SDK for visual studio, and QtCreator, it automatically recognised that Visual Studio had to be used, and it has no problem finding it. I don't know how he did find it though. Note : it doesn't have to do with any 'path' setting, because Visual Studio is not in my path, and QtCreator finds it anyway.

In QtCreator you could check under the 'Projects' icon on the left, then 'run settings', then expand the details of the run environment, and then check the 'PATH' variable that is used in the build. Visual Studio should be in it.

About QtCreator vs Visual Studio - without wanting to start an 'editor' war - it is not true that 'Visual studio generates smaller/faster/... better binaries than QtCreator". Both are a development environment, not compilers or linkers. Both can use the same MSVC compiler/linker, so they can generate identical binaries. If you use QtCreator with MingW instead, you will get differences of course.

Best regards,
Marc

squidge
6th October 2010, 23:23
If you want to be picky about it, theres no such thing as a MSVC compiler, as the word 'Visual' is strictly for the IDE and only makes sense there, not the compiler. The banner displayed when running the compiler/linker also says "Microsoft (R) 32-bit C/C++ Optimizing Compiler". It never mentions the word 'Visual'.

Secondly, Without any modifications, QtCreator uses GCC, Visual Studio uses the Microsoft C/C++ compiler/linker, so I'd say it's fair enough to say that Visual Studio generates smaller/faster/better binaries than Qt Creator. After all, you are never going to use MinGW under Visual Studio.

Finally, 'cl' is the compiler, not the linker. In the displayed banner, it clearly states this. The incremental linker is called 'link'.

Sure, if you tell QtCreator to use the Microsft C/C++ compiler, it will generate the exact same code, should you give it the exact same switches.

marcvanriet
7th October 2010, 11:48
Agreed about the cl and Visual and so.

Not that QtCreator cannot use the MS compiler/linker without modifications. If you download and install "Qt libraries 4.7.0 for Windows (VS 2008, 226 MB)" from the Qt website, and download and install QtCreator (or was it already included, I don't remember) then QtCreator automatically recognises that the MS compiler/linker has to be used. No need to rebuild or figure out any settings yourself.

Regards,
Marc