Compiling Qt 5.3.1 under Visual Studio 2010 Professional (windows 7 - 64 bits)
-
Hello,
I am a newbies with Qt (from France).
I have downloaded the source code "qt-everywhere-opensource-src531.zip".
After unpacking the source files in C:\Qt\5.3.1 directory, I set up environment variables.- QMAKESPEC = win32-msvc2010
- QTDIR = C:\Qt\5.3.1
- Path = ....;%QTDIR\bin\
Then I open the VS2010 console. I changed the current directory with a "cd %QTDIR%"
I launched the following command : "configure & nmake & nmake clean"The compilation lasted 1 hour and 15 minutes (old PC centrino 2 but with a SSD disk).
Problem n°1 : the compilation sent me an error : "The Directx SDK bould not be detected ... disabling the ANGE backend. I went further.
Problem n°2 : I lauched VS2010, set up a new makefile Project with different settings :
- Exe directory : $(QTDIR)\bin
- Include directory : $(QTDIR)\include
- Library directory : $(QTDIR)\lib
I wrote the main.cpp with the basic Qt example :
@#include <QtGui/qapplication.h>
#include <QtGui/qpushButton.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton bouton("Bonjour les Zéros !");
bouton.show();
QObject::connect(&bouton, SIGNAL(clicked()), &app, SLOT(quit()));
return app.exec();
}@I lauched the build, and received different errors : "Could not find the qapplication.h" !!!
I was supprised to see that the bin, lib, include directories were not in the "C:\Qt\5.3.1" directory, but in the "C:\Qt\5.3.1\qtbase" directory !!
The qapplication.h is in the "C:\Qt\5.3.1\qtbase\include\QtWidgets" directory !!Why ????
I tried to change the %QTDIR% variable to "C:\Qt\5.3.1\qtbase" and change the main.cpp as this :
@#include <QtWidgets/qapplication.h>
#include <QtWidgets/qpushbutton.h>@I builded it again, and this time, here is the error from VS2010 : the Qt5Guid.lib is not found (it does not exist on my PC !!!)
bq. 1>Build:
1>
1> Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
1> Copyright (C) Microsoft Corporation. Tous droits rÚservÚs.
1>
1> "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" -f Makefile.Debug
1>
1> Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
1> Copyright (C) Microsoft Corporation. Tous droits rÚservÚs.
1>
1> echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID / 24 / RT_MANIFEST / "debug\TutoQt.exe.embed.manifest">debug\TutoQt.exe_manifest.rc
1> if not exist debug\TutoQt.exe if exist debug\TutoQt.exe.embed.manifest del debug\TutoQt.exe.embed.manifest
1> if exist debug\TutoQt.exe.embed.manifest copy /Y debug\TutoQt.exe.embed.manifest debug\TutoQt.exe_manifest.bak
1> link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\TutoQt.exe.embed.manifest /OUT:debug\TutoQt.exe @C:\Users\EMMANU~1.GUI\AppData\Local\Temp\nm6325.tmp
1>LINK : fatal error LNK1104: impossible d'ouvrir le fichier 'C:\Qt\5.3.1\qtbase\lib\Qt5Guid.lib'
1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.EXE"'á: code retour '0x450'
1> Stop.
1>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe"'á: code retour '0x2'
1> Stop.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: La commande "qmake & nmake" s'est arrêtée avec le code 2.
1>
1>ÉCHEC de la build.
1>
1>Temps écoulé 00:00:01.02
========== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========Here it is !
Could you help me ?
Thanks a lot for all. -
Hi,
-
If you want an ANGLE build you need to install the DirectX SDK, otherwise configure your build with -opengl desktop
-
It's normal, Qt has been modularized for the 5 series. If you want to use Qt from Visual Studio, you should consider using the VS-addin otherwise, Qt Creator is a very good alternative.
On a side note, with nmake clean you have removed everything you just built.
-
-
Hi, and welcome to the Qt Dev Net!
Where did you get your instructions for building Qt 5? Here is a good guide: http://qt-project.org/wiki/Building_Qt_5_from_Git Just ignore the part about git -- You can use qt-everywhere-opensource-src531.zip
But I'm curious:
Why do you want to compile Qt yourself, instead of downloading a precompiled package?
Why do you use MSVC 2010 instead of MSVC 2013?
[quote]I set up environment variables.
QMAKESPEC = win32-msvc2010
QTDIR = C:\Qt\5.3.1
Path = ….;%QTDIR\bin[/quote]You don't need to set any environment variables.- The build system will automatically detect your compiler, so you don't need QMAKESPEC.
- The build system ignores QTDIR.
- I often encourage people not to put Qt in PATH. You don't need it, and it can cause problems sometimes.
[quote]I launched the following command : “configure & nmake & nmake clean”[/quote]Like SGaist said, nmake clean is supposed to delete the files you built! The correct command is nmake install.
However, in order to use nmake install, you need to set the "-prefix" configuration option. "-prefix" is the folder where you want to install Qt.
You should run configure like this:
@
configure.bat -prefix "C:/Qt/Built/5.3.1/msvc2010" -opensource -confirm-license -nomake examples -nomake tests -opengl desktop
@Notes:
- "-confirm-license" will automatically apply the "-opensource" license. If you don't include it, you need to answer a prompt.
- Your "-prefix" should be different from your source code folder. If you want to install to C:\Qt\5.3.1, then you should extract qt-everywhere-opensource-src531.zip to a different folder.
- "-nomake examples" and "-nomake tests" will reduce compilation time.
- "-opengl desktop" will get rid of the warning about the DirectX SDK. However, this option only works if your graphics card supports OpenGL 2.0 or higher. If you don't have OpenGL 2.0 or higher, you need to remove this option and install the DirectX SDK.
[quote]I was supprised to see that the bin, lib, include directories were not in the “C:\Qt\5.3.1” directory, but in the “C:\Qt\5.3.1\qtbase” directory !!
The qapplication.h is in the “C:\Qt\5.3.1\qtbase\include\QtWidgets” directory !!Why ????[/quote]Because you didn't run nmake install
-
Hy,
I am very glad for all your answers. Thank you : I am not alone :)
To SGaist : I am not sure to understand your answer. As I told you, I am new to Qt. For the time being, I need not to use DirectX. What is ANGLE : I have to learn about it. You advise me to install VS-addin ? By the past, I installed Qt Creator but to work with Code::Blocks and MinGW. But I do not understand the link between Qt Creator and VS2010.
To JKSH : I found instructions for using Qt with VS2010 on a french website "here":http://fr.openclassrooms.com/informatique/cours/utiliser-qt-avec-visual-studio-2010
This concerns Qt 4.7. The toturial explains that I need to build Qt !
Is it necessary to build QT5 or not ?? You said that I can use only a precompiled package. Like "Qt Online Installer for Windows (14 MB) ", and this could work simply with VS2010 ?
I have a license for VS2010 but not for VS2013. This is why I use VS2010.Can you direct me more clearly on what to implement and how to build Qt projects in VS2010? After that, I would like to use Qwt too.
Thanks to you.
-
Hi,
[quote]For the time being, I need not to use DirectX. What is ANGLE : I have to learn about it.[/quote]See http://qt-project.org/wiki/Qt-5-on-Windows-ANGLE-and-OpenGL -- basically, Qt uses OpenGL for Qt Quick (QML GUIs). However, some Windows PCs don't have enough OpenGL support, so Qt gives the option of using ANGLE to convert OpenGL functions to DirectX functions.
If you don't plan to use QML, you don't need to worry about OpenGL/ANGLE.
[quote]You advise me to install VS-addin ? By the past, I installed Qt Creator but to work with Code::Blocks and MinGW. But I do not understand the link between Qt Creator and VS2010.[/quote]
- Qt Creator is an IDE (Integrated Development Environment).
- Visual Studio is an IDE.
- When you install Visual Studio, you get the IDE and a compiler.
- The Qt Creator IDE can use the Visual Studio compiler or the MinGW compiler (or a few others)
[quote]I found instructions for using Qt with VS2010 on a french website "here":http://fr.openclassrooms.com/informatique/cours/utiliser-qt-avec-visual-studio-2010
This concerns Qt 4.7. The toturial explains that I need to build Qt ![/quote]That tutorial is extremely old. Qt has changed a lot since then. Don't follow that tutorial.[quote]Is it necessary to build QT5 or not ??[/quote]Not necessary :)
[quote]You said that I can use only a precompiled package. Like “Qt Online Installer for Windows (14 MB) “, and this could work simply with VS2010 ?[/quote]Yes.
The Online Installer is a package manager. Through it, you can select and download precompiled packages like "Qt 5.3.1 for Windows 32-bit (VS 2010, OpenGL, 537 MB)".
[quote]I have a license for VS2010 but not for VS2013. This is why I use VS2010.[/quote]Do you want to use Pro features of the Visual Studio IDE? If not, you can download VS2013 Express for free, and use Qt Creator as your IDE.
-
Hy,
Thanks for your quick answer !
OK for QML (see later).
I have to download the Qt 5.3.1 for Windows 32-bit (VS 2010, OpenGL, 537 MB)
Do I need to configure VS2010 or VS2013 in order to use Qt ?
Do you advise me to prefer Qt Creator with the VS20XX compiler ?
By the past, I downloaded the VS2013 Express, but I wanted to build a XLL, and for that, I needed to use add-ins (not with the VS2010 PRO). But you advise me to use VS2013 Express with Qt ?
Waiting for your return, I'll start downloads
Best regards. -
If you install Qt 5.3.1 VS 2010, then you need to also have Visual Studio 2010 installed. You can't mix different versions has Microsoft compilers are not compatible one with the other.
Qt Creator is just an IDE, it doesn't come with a compiler so you still need to install e.g. Visual Studio. Since you're new to Qt, then go with Qt Creator, it's optimized for Qt development (you can still use it for development of software not using Qt though).
-
Hy,
Finally, I followed the recommandation of JKSH :
Clear of all environment variables
Installation of VS2013 Express
Installation of Qt 5.3.1 for Windows 32-bit (VS 2013, 559 MB)
Installation of Qwt 6.1.0 (need to launch nmake and nmake install)
Use of Qt Creator for build Qt project and Qwt Project
All is right.
Thanks for all to JKSH and SGaist for your help.
Best regards.