Building QT for msvc2015 - and get working projects?
Solution 1
Here is a complete walkthrough:
How to compile Qt 5 under Windows or Linux, 32 or 64 bit, static or dynamic on VS2010, VS2012, VS2013 or VS2015 Express or g++.
You might want to uninstall all previous Qt.
Solution 2
I have Qt built for VS2015 as well as VS2013 and for 5.50 onwards it shouldn't need anything particularly special to get it to build successfully. I tend to use a cut down version of the Walkthrough that @jafar's mentions (and also closer to the method in the official docs')
- Clone the qt5 repository or unzip the source
- Start a command prompt. IMPORTANT: create the correct 'VS2015 x86 or x64' prompt
-
DON'T edit the
msvc-desktop.conf
as mentioned in the Walkthrough. (Qt can't be built with the /MT flag) -
Run configure:
configure -debug-and-release -opensource -platform win32-msvc2015 -opengl desktop -nomake examples -nomake tests
Build with
jom -j 8
(I find you get diminishing returns beyond that) ornmake
. If you omit the examples and tests I can build the whole of qtbase in about 10-15 minutes- Run
jom install
ornmake install
JCh3ss
Updated on June 04, 2022Comments
-
JCh3ss almost 2 years
There already is a quite related question (rq) here, but it is not specialized enough and my reputation is not high enough to ask for more advice in the comments ... yet, time is running and I've got to get somewhere. Once the original question is answered, this one can and should be deleted.
What I want: Working in Visual Studio 2015, using the qt-library. That's it.
What I did:
- Install vs2015, works
- Download the qt5.5.0 source, built it following the (rq) instruction using jom (nmake worked the same, just was slower)
- Install the qt package extension for vs2015, also following (rq)
The first error: The building-process didn't create any mkspecs, so i wasn't able to set the directory in the QT-options in visual studio: "This QT version uses an unsupported makefile generator (used:, supported: MSVN.NET, MSBUILD)"
- I tried to hack that by replacing it with the mkspec-folder of an installed version to I was able to select the qtbase-folder in the Qt Options.
- Played around with the library-directories, the include-directories and the additional-dependencies of the VS-Project. No matter what I did, the include-files where not found.
As this didn't work out, I installed qt 5.5.0 mingw492_32 with the installer. Using that I was able to create a new project with the QTCreator. It compiled in the QTCreator. After that I executed
qmake -platform win32-msvc2015 -tp vs
to convert the project into a Visual-Studio-project, while qmake was the executable from the previously BUILT version, not the installed one, the include-files where still not found in visual studio.
What am I doing wrong? The library-directories, the include-directories and the additional-dependencies look fine to me in the converted project.
EDIT 1: I followed the walkthrough and everything built successfully. Yet, the mkspecs-folder is still empty. Creating a Qt-Widget-application with the Qt Creator endts up in a crashing app (no changes were made to the default code):
Second Chance Assertion Failed: File minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp, Line 980
Calling
qmake -platform win32-msvc2015 -tp vs
also isn't successfull:
qmake -platform win32-msvc2015 -tp vs WARNING: Unable to generate output for: D:/_Daten/_Studium/Bachelor-Thesis/Visual-Studio/VISAR-FSA/GuiTest/Makefile.Debug [TEMPLATE vsapp] WARNING: Unable to generate output for: D:/_Daten/_Studium/Bachelor-Thesis/Visual-Studio/VISAR-FSA/GuiTest/Makefile.Release [TEMPLATE vsapp]
EDIT 2:
Concerning the mkspecs: Turns out I had to call both:
jom -j 8 jom install
Now all mkspecs are created. The official documentation made me think that the second one only was an option for the build when a destination path was set. Yet, a freshly created Qt Widget Application in Qt Creator, with the built and installed QT-version and the correct compiler, still won't compile. A LNK2019 occures in [qtmain.lib(qtmain_win.obj)], telling me that there is a link to a symbol "__imp__CommandLineToArgvW@8" in function "_WinMain@16", that was not resolved.
-
Kuba hasn't forgotten Monica over 8 yearsQt versions are completely isolated. You should never add any Qt version to any global environment variable. Uninstalling previous Qt versions is pointless: in normal development, you will have multiple versions installed side-by-side. It all works.
-
JCh3ss over 8 yearsThank you for the response, but that walkthrough didn't help me out by now...updating question
-
JCh3ss over 8 yearsThanks! I'm indeed not sure if I was using the correct prompt, because the title doesn't contain the architecture - how do I know? - Also, are the mkspecs created when you did that? I will go for another attempt tomorrow and will tell you if it worked or not.
-
the_mandrill over 8 yearsI do have a mkspecs directory in the installed directory containing
win32-msvc2015
along with many others. You can check that you have the right command prompt by runningcl
- it should sayMicrosoft Compiler Version 19.00... for x64
(or x86) -
JCh3ss over 8 yearsOkay, concerning the missing mkspecs: It was the missing jom install call. That one is fixed, thanks a ton! - Yet, when creating a new QT widget applycation, it still won't build: A LNK2019 occures at [qtmaind.lib(qtmain_win.obj)], telling my that theres a link to an unresolved symbol "__imp__CommandLineToArgvW@8" in function "_WinMain@16" ...
-
the_mandrill over 8 yearsThat's a Windows API - add
shell32.lib
to your link libraries (see msdn.microsoft.com/en-us/library/windows/desktop/…)