Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt Integration with Visual C++ 2010 Express Edition, how do I do this correctly?
I've been having some trouble getting Qt 4.7.3 (open source) set up with my Visual C++ 2010 Express Edition. I have quite a few reasons for using VC++ over MinGW or Qt Creator, mostly just because I want to keep my develpment environment consistent.
I started out by using the online install for Qt 4.7.3 for Windows (using Windows 7). Here are the features I currently have installed:
!http://img585.imageshack.us/img585/1017/qtconfig1.jpg(My Qt installation settings)!
After I installed that, I went to C:\QtSDK\QtSources\4.7.3 via the command line and typed in "configure -platform win32-msvc2010". I set it to Open Source Edition and accepted the licence agreement, here's the output that it gave me:
!http://img171.imageshack.us/img171/1324/qtconfig2.jpg(Qt config command line results)!
I can assume that a return code of -1 isn't good, not to mention the ".lib not found" error messages. One problem is I honestly have no clue what "qmake" and "nmake" are supposed to do or how they're supposed to affect my VC++ workflow. I really haven't gone very far beyond adding .libs and include files in terms of compiler settings, so I suppose I'm not surprised at how far I've gotten with this so far. :P I have quite a bit of experiance with software coding and C++'s syntax, but not as much experiance with implementing new development environments in this kind of depth.
So what should I do now to get the most ideal Qt workflow with VC++? My main goal in terms of using Qt are to create a world editor and other game engine tools using OpenGL 3.x (and possibly OpenGL ES once I focus more on mobile development), as well as Win32 when needed. Help is appreciated! :)
There is a visual studio plugin for Qt development available somewhere. I am not sure that one will work with visual studio express though (wasn't there something about that not supporting plugins?).
Or just give Qt Creator a try... that does work really well and you get way better support for it here in this forum:-)
A common problem with installations / compilations involving MSVC is the command (DOS) prompt. If you just open a command windows you cannot build and install Qt, because it cannot find the MSVC tools.
Open the command prompt from MSVC under "tools->Visual Studio 2010 Command Prompt" or similar. Then it will find the tools.
jim_kaiser last edited by
To answer your "nmake" question. That is just the equivalent of "make" on windows. "qmake" is of course, a part of the Qt build system, used to generate the make files from the .pro files or generating the .pro files itself.
Now, the reason you get an error about nmake is because of the paths. Use the Visual Studio Command Prompt to have the paths automatically set so you can use the VS build tools. Or in a normal cmd prompt, you can set the environment, as I remember, something like
@ <MY_VS_INSTALLATION>/VC/vcvarsall.bat <platform> @
or running the appropriate bat file like "vcvars_32.bat". Hope that help you solve your problem.
Excellent advice from everyone so far, it's helped me take a huge step in this problem. Here's what I'm doing now:
I've completely uninstalled the Qt SDK I had before, since it had many features that I didn't need.
I installed the open source variant of Qt from http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.zip
Extracted it to C:\
Opened the VS2010 command line and went to C:\qt-everywhere-opensource-src-4.7.3
Ran configure -platform win32-msvc2010
Entered open source
Agreed to licences
And now it's actually working like it's supposed to. It's still loading so I'll update when I get more results from this.
EDIT: It says "Qt is now configured for building. Just run nmake."
So now will I be able to start and build projects via the IDE, or do I have to go to nmake to create an executable for my project?
Well, you are apparently still in the configure phase. The compiling takes even longer.
In case you have a multi-core machine and are wondering why you cannot use more cores with nmake. I had the same problem a while ago. "This thread might be of interest for you":http://developer.qt.nokia.com/forums/viewthread/5843
So how do I use nmake exactly? Am I able to start Qt projects from the VC2010 IDE now? I'm not very intuitive with makefiles or command line compiling, I'm just starting to get into this. xD
Either you just use nmake. But this will use only one core than. There is a Qt tool called jom. If you click on the link I have provided in previous post, you will be let to some details.
Respectively here is the link I had received "Speeding up Visual C++ Qt Builds":http://labs.qt.nokia.com/2009/03/27/speeding-up-visual-c-qt-builds/
Alright. So I can create a new project in Visual Studio called "Hello Qt", add the includes and libs, write some Qt code, go to the project directory via VS command line, and type nmake? (or jom once I get the hang of command line compiling, lol) But is this what I need to do? Will it result in an executable?
Or can I even just compile it in the IDE instead? Or how do I do more advanced things like managing debug and release builds, building DLLs, etc?
EDIT: Alright, I've been reading nmake documentation on MSDN and it makes sense, it just compiles everything accourding to a makefile. Configure.exe must've made that makefile.
So I'll just wait until nmake finishes...
First you have to build Qt Libs with Visual C++ 2010 compiler. To do this you need first to run something like this from VS C++ Command Promt in Qt source directory:
@configure -debug-and-release -opensource -platform win32-msvc2010@ There are a number of other arguments for configure, you can take a look "here":http://doc.qt.nokia.com/4.7-snapshot/configure-options.html.
Second, you need to run
@jom@ if the latter is installed.
After this steps you will finally have Qt libraries built (building will take 2-3 hours).
Now you can compile your application with MS VC++ and link it agains Qt Libraries that were just built. You can use either Qt Creator for this or VS with "Qt VS Add-in":http://doc.qt.nokia.com/vs-add-in-1.1.7/index.html. Unfortunately, it’s impossible to install this Add-in on Express version of VS.
When you have started the configure this is only part of the story. After the configure concludes you should see the next step. If I remember correctly, there are two possibilities offer. One is just starting "nmake". This will finally create the Qt tools. The second possibility listed is "nmake confclean" or similar, if you want to start all over again.
After you have generated the Qt tools and libs you should be able to do the rest through IDE. However, I do not know how th handle from that point since I am not using VS express. I am using VC2005 with a license.
[quote author="Tobias Hunger" date="1308811614"]There is a visual studio plugin for Qt development available somewhere. I am not sure that one will work with visual studio express though (wasn't there something about that not supporting plugins?).
This could be an obstacle for you. I cannot verify.
As already suggested by Tobias Hunger there is a possibility to use QtCreator as an IDE for your purposes. Also in Creator you can use the MS compiler.
Where will the libraries that I'll need to compile with be stored? (I'm still generating them with nmake) And would I be able to use cl.exe to compile my Qt projects without the add-in? Or can I just specify my include files and libs in the IDE, and build normally?
Yes, you can use cl.exe. To my understanding it is the same as in other vc versions.
The location of the Qt libs should not be the problem. Either you have used a prefix in the configuration step, but I think this is only available in linux, or they will be in the directory where you were building the Qt version.
So if you unzip into "C:\Qt" for example, there should be a directory lib now. There you have the libraries you need for linking and also the dlls. The includes are under include. All is straight forward. You need to use the include in the IDE for compilation.
You should try to install the "VS-Add-In":http://qt.nokia.com/downloads/visual-studio-add-in and see if you can use it.
Are you planning to use Qt's designer for gui stuff?
Actually, I would recommend to use Qt Creator as an IDE for developing with Qt. I personally find it very handy (much more handy than Visual C++ IDE). You will only need to install CDB in order to debug application, compiled with MS VC++, in Qt Creator (see Creator documentation for more info).
However, if you are new to Qt, it would possibly be much easier to start first with prebuilt versions of Qt Libs: just download Qt libraries 4.7.3 for Windows (minGW 4.4, 319 MB) and Qt Creator 2.2.1 for Windows (52 MB) from "here":http://qt.nokia.com/downloads, install them and start using. As you become more familiar with Qt, you will find no problems in building either Qt Libs, Qt Creator or your application with every supported toolchain.
If you are not familiar with Visual Studio and you do not require the microsoft compiler, it is certainly a good recommendation to consider Qt Creator.
[quote author="koahnig" date="1308858426"]If you are not familiar with Visual Studio and you do not require the microsoft compiler, it is certainly a good recommendation to consider Qt Creator. [/quote]
Visual Studio support of C++ is not so impressive comparing to C# or VisualBasic.NET. So, even if you’re familiar with Visual Studio, using of Qt Creator for development with Qt is, possibly, better approach.
Just personal opinion, of course.
I've tried to install the VS add-in, it said that express wasn't compatable.
But how should I create a makefile if I'm only using VC++, in which case I don't have any .pro files?
I'll consider using the Qt IDE for all of my projects that use Qt, I'm just worried about discrepancies between my Qt utilities and external libraries that they use (such as OpenGL, OpenAL, STL, etc) and other components of my game engine, such as the runtime foundation system which won't even use Qt.
So I suppose if I'm still going to be using VC++ for Qt development (if consistency is required), the question I have is how would I create a makefile for my Visual Studio project files that use Qt?
Work with external libraries will not depend on what IDE you use.
You need qmake and pro file because qmake will not only generate Makefile, it will as well call "moc":http://doc.qt.nokia.com/4.7/moc.html to generate a number of extra *.h and *.cpp files (this is because Qt uses some C++ language extensions that are not supported by compilers, e.g. slots and signals, advanced RTTI).
Qt supports OpenGL ("examples":http://doc.qt.nokia.com/4.7/examples-opengl.html), you can easily use STL things (though Qt has its own useful containers), you can use Qt with Boost. I see no reason for Qt not to be compatible with OpenAL. And, again, it all doesn’t depend on IDE.
I will strongly recommend you to spend some time learning Qt essentials, before you use it in your application. Qt is powerful and easy-to-use library, but it needs some effort to become familiar with. Luckily, there’re a lot of documentation, tutorials, examples and so on. This is some links:
- "Qt Documentation":http://doc.qt.nokia.com/
- "Qt Learning materials":http://qt.nokia.com/developer/learning/online/training/
- A lot of examples in _«QtDir»\examples_. They are also explained in documentation.
- And this forum, of course.
[quote author="AutoBot" date="1308859391"]
So I suppose if I'm still going to be using VC++ for Qt development (if consistency is required), the question I have is how would I create a makefile for my Visual Studio project files that use Qt?[/quote]
You will need to create .pro file (its format explained "here":http://doc.qt.nokia.com/4.7/qmake-tutorial.html and "here":http://doc.qt.nokia.com/4.7/qmake-common-projects.html). If you use Qt Creator or VS with Qt Add-in, all this will be generated automatically.
To build your project you should then run qmake and then nmake or jom.
This makes a lot of sense now, I'll start working with Qt creator (and a different API when I'm not using Qt) and see how I do with that.
[quote author="DSav" date="1308858917"]Visual Studio support of C++ is not so impressive comparing to C# or VisualBasic.NET. So, even if you’re familiar with Visual Studio, using of Qt Creator for development with Qt is, possibly, better approach.[/quote]
I am certainly not someone trying to defend MS products by all means. However, I am using them for long time now. My experience is limited to C++ there. I have started recently with Qt Creator on Linux. So far, I have not found a very good reason to switch completely. By saying so, I have to admit it is probably a part of laziness behind. The philosopies are different and I struggle quite a bit to get things done in Qt Creator.
However, my personal recommendation is, if you have to get used to both IDEs anyhow, I would choose Qt Creator.
peter999 last edited by
you first should start with Qt documentation. Express versions does not support add ins, you can read the restrictions on the microsoft pages.
Qt should be created on command line (you also need da different commandline when using 64 bit), after configure call simply nmake.
To work with express VS 2010, you have a lot of work to configure the pre runs, i.e moc, uic, and so on. It is better to work with the qmake pro-files, and use express as editor.... VcProjX creating by hand is a hard working job...
So as koahnig wrote, Qt Creator is better for you. You can still use VS 2010 compiler, for debugging you need to install debugging tools from Microsoft.... And Qt Creator has "VS Addin" included.....
Or buy VS Studio 2010 professional, than you are able to work with VS Addin..
jensen82 last edited by
Why did they add prepared libraries for VC2005 and VC2008 to the QtSDK-Installer and not VC2010?
Anjan369 last edited by
hi there is a way to buid a Qt project in msvc express editon..download the pdf from the link..
in the second part of PDF procedure is given...hopefully it will be helpfull for you..