Below I provided a simple step by step instruction on how to compile QT 5.7 with VS2015 assuming you already have VS2015 and Git client installed on your Windows machine.
Install Perl, Python and Ruby.
To get QT 5.7 sources open Git Bash and run the following command (the repository has some submodules, so “recursive” option is required), see the list of possible clone here at the bottom of the page:
git clone --recursive https://github.com/qtproject/qt5.git --branch 5.7
Create a bat file called configureqt.bat with the following content:
set PATH=%PATH%;"C:\Program Files (x86)\Portable\ruby-2.3.0-i386-mingw32\bin";C:\Perl\bin;C:\Python27 D: cd D:\Repos\qt5\ set _ROOT=D:\Repos\qt5 set PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH% set QMAKESPEC=win32-msvc2015 set _ROOT= configure -debug -nomake examples -opensource
Another alternative configuration (last line in the bat file) is:
configure -debug -confirm-license -opensource
it compiles QT with all the examples and does not ask to accept the license.
Probably the following can help to switch QT branch:
git checkout 5.9 git submodule update --init --recursive
Open VS2015 Command Prompt x86 and run configureqt.bat. If everything went right run nmake and wait a few hours.
To create your first QT project in VS2015 go to Tools->Extensions and Updates and install Qt5Package:
Restart VS2015, Go to QT5->Qt Options and specify the path to QT binaries:
Go to File->New->Project and select Templates->Visual C++->Qt5 Projects->Qt Application:
Click OK, and select modules you want to include in your project:
and then click Finish.
I built QT 5.9 a bit differently: in Developer Command Prompt for VS2015 I run the following commands:
git clone --recursive https://code.qt.io/qt/qt5.git --branch 5.9 set PATH=%PATH%;"C:\Program Files (x86)\Portable\ruby-2.3.0-i386-mingw32\bin";C:\Perl\bin;C:\Python27 configure -prefix %CD%\qtbase -debug -confirm-license -opensource -nomake examples -nomake tests nmake
There is alternative way how to clone and build QT that I used on Ubuntu with GCC 5.4.1 and CMake 2.8.12.2 (there is no branch 5.9.1 but only 5.9, so the tag is used):
sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-7 g++-7 sudo update-alternatives --remove-all gcc update-alternatives --display gcc sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10 --slave /usr/bin/g++ g++ /usr/bin/g++-7 git clone --recursive https://code.qt.io/qt/qt5.git v5.9.1 ./configure -prefix /home/dmitry/examples/libs/qt591 -debug -confirm-license -opensource -nomake examples -nomake tests -skip qtquick1 -platform linux-g++
The output message was:
... OpenGL: Desktop OpenGL ....................... yes OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no ... Note: Also available for Linux: linux-clang linux-icc Note: Dropped compiler flags '-pthread' when detecting library 'glib'. Note: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing. Qt is now configured for building. Just run 'make'. Once everything is built, you must run 'make install'. Qt will be installed into '/home/dmitry/examples/libs/qt591'. Prior to reconfiguration, make sure you remove any leftovers from the previous build.
Without ‘./init-repository –branch -f’ there was compiler error:
graphicsitems/qdeclarativetextinput.cpp: In member function ‘void QDeclarativeTextInput::setCursorVisible(bool)’: graphicsitems/qdeclarativetextinput.cpp:517:17: error: ‘class QWidgetLineControl’ has no member named ‘setCursorBlinkPeriod’
To reconfigure QT I used (‘make confclean’ did not work):
git submodule foreach --recursive "git clean -dfx"
The full list of the repositories installed on my Ubuntu system is:
sudo apt-add-repository ppa:ubuntu-toolchain-r/test sudo apt-add-repository ppa:neon1ks/bumblebee sudo apt-add-repository ppa:beineri/opt-qt551-trusty sudo apt-add-repository ppa:developmentseed/mapbox sudo apt-add-repository ppa:x2go/stable
See also:
QT doesnt work with visual studio when compiled using MinGW
building on Ubuntu, see https://forum.qt.io/topic/82880/unable-to-get-qt-5-9-from-github-com
584 ./configure -debug -confirm-license -opensource -qt-xcb –prefix=/home/dmitry/examples/tools/install/
585 ll /home/dmitry/examples/qt5/qtbase/src/corelib/global/qconfig.cpp
586 cd qtnetworkauth
587 ll
588 ls .git
589 ls .git/modules/
590 ls .git/modules/qtnetworkauth
591 git status
592 git reset –hard
593 git status
594 git clean -xdf
595 git status
596 git submodule reset
597 git submodule update –init
598 ll -d qtx11extras/
599 git checkout qtnetworkauth
600 ll qtnetworkauth
601 ll -d qtnetworkauth
602 git status
603 cd qtnetworkauth
604 git reset –hard .
605 git status
606 cd –
607 ll .git/modules/qtnetworkauth
608 git checkout master
609 git branch -a
610 git checkout origin/HEAD
611 git status
612 git reset –HARD
613 git reset –hard
614 git status
615 git submodule foreach git reset –hard
switching to a branch (see http://wiki.qt.io/Android):
git checkout v5.9.1
git submodule update –recursive
Installing GCC9:
sudo apt-get install gcc-9 g++-9
sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-9 10 –slave /usr/bin/g++ g++ /usr/bin/g++-9
Ubuntu 20.04:
Install C compiler by installation of the development package build-essential:
sudo apt install build-essential
g++ –version
g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0