QT5.7.0 Using Visual Studio 2015 compilation under WIN10 (Target platform XP)

Source: Internet
Author: User
Tags odbc



Environment: win10+vs2015+qt5.7.0



Target: Compile QT that can run on Windows XP



Baidu and Bing can not find the results of a successful operation, most of them can be compiled successfully, and the perfect solution "EXE is not a valid Win32 program", but the program is still unable to display the normal window.



At this time there will be a crash, the specific location is Qwindows.dll, but use depends view also didn't see qwindows.dll there is a problem, some people will encounter qwindows.dll dependent



Kernel32.dll in XP does not have a corresponding interface, the specific interface does not remember, and finally see the problem is QT5.5, has been fixed.



Repeated attempts to http://www.cnblogs.com/bbxx111/p/5461069.html this post method, the full 3 times compile, still not, during the qt-build changed. BAT script inside the set cl=/d_using_v140_sdk71_;%cl%, according to the Post's bat always have "__useheader" repeatedly defined warning, as software development, I can not stand this kind of warning, According to the official doc (http://doc.qt.io/qt-5/windows-issues.html), modified bat warning is still, finally the integration of StackOverflow and QT Forum experience compiled successfully.



The final compilation method is as follows:


Modify% QTDIR% \ qtbase \ qmake \ Makefile.win32 and add -D_USING_V110_SDK71_ after CFLAGS_BARE
Modify% QTDIR% \ qtbase \ mkspecs \ common \ msvc-desktop.conf,
Add _USING_V110_SDK71_ to DEFINES;
Modify QMAKE_LFLAGS_CONSOLE = / SUBSYSTEM: CONSOLE, 5.01
Modify QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01

QTDIR is a directory of QT source code.

qt-build.bat is as follows:

REM Set up \ Microsoft Visual Studio 2015, where <arch> is amd64, x86, etc.
CALL "C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ VC \ vcvarsall.bat" x86

REM ********** Update include & lib to support xp win sdk 7.1A **********
SET PATH = C: \ Program Files (x86) \ Microsoft SDKs \ Windows \ v7.1A \ Bin;% PATH%
SET INCLUDE = C: \ Program Files (x86) \ Microsoft SDKs \ Windows \ v7.1A \ Include;% INCLUDE%
SET LIB = C: \ Program Files (x86) \ Microsoft SDKs \ Windows \ v7.1A \ Lib;% LIB%
SET CL = / D_USING_V110_SDK71 _;% CL%

REM ********** 3rd party build tools binaries: ruby, perl, python **********
SET PATH = C: \ Ruby23-x64 \ bin; C: \ Perl64 \ bin; C: \ Python27;% PATH%

REM ********** Set up qt source env **********
SET _ROOT = C: \ Qt \ qt-everywhere-opensource-src-5.7.0
SET PATH =% _ ROOT% \ qtbase \ bin;% _ ROOT% \ gnuwin32 \ bin;% PATH%

REM Uncomment the below line when using a git checkout of the source repository
REM SET PATH =% _ ROOT% \ qtrepotools \ bin;% PATH%
SET QMAKESPEC = win32-msvc2015
set _ROOT =

REM Generate makefile
configure.bat -mp -confirm-license -opensource -platform win32-msvc2015 -developer-build
-shared -target xp -prefix D: \ Qt5.7.0-shared-win32-vs2015-xp -qt-sql-sqlite -qt-sql-odbc
-plugin-sql-sqlite -plugin-sql-odbc -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop
-qt-freetype -no-qml-debug -no-angle -nomake tests -nomake examples -skip qtquickcontrols
-skip qtquickcontrols2 -skip qtsensors -no-directwrite

In order to make the layout look good, the final configuration adds line breaks. If you need to copy, please remove the line breaks to avoid compilation exceptions. 


The rest is the execution of NMAKE, about 2 hours, after the completion of the compilation to perform NMAKE install installation, the above script is configured to install the path is D:\QT5.7.0-SHARED-WIN32-VS2015-XP.



The above method may exist redundant things, the project after the tight, first solve the project and then to carefully review and improve.



There are 2 points to note for this method:



1, vs2012 need to compile after the program can run on XP must and can only define macro _using_v110_sdk71_, some people will say V110 is not to follow the version of VS to go? If you try to solve the __useheader macro redefinition, you will find that vs2015 in the header file inside the judgment is also _using_v110_sdk71_.



2, configure configuration script The key point is-target XP and-no-directwrite, the first is to configure the target platform for XP, the second is the way Windows font rendering. The portal is here: https://msdn.microsoft.com/zh-cn/library/windows/apps/dd368038.aspx, which explicitly states that Directwrite must be a platform above windows 7.



Directwrite configuration to thank HTTPS://FORUM.QT.IO/TOPIC/62162/QT-5-6-DOESN-T-COMPATIBLE-WITH-WINDOWS-XP/12 for the answer to the question.



Reference documents:



1, http://www.cnblogs.com/bbxx111/p/5461069.html



2, http://doc.qt.io/qt-5/windows-issues.html



3,HTTPS://FORUM.QT.IO/TOPIC/62162/QT-5-6-DOESN-T-COMPATIBLE-WITH-WINDOWS-XP/12



4. https://msdn.microsoft.com/zh-cn/library/windows/apps/dd368038.aspx



5, http://www.qtcn.org/bbs/read-htm-tid-56157.html






QT5.7.0 compiled with Visual Studio 2015 under WIN10 (target platform XP)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.