Building Qt 4.8.7 with Visual Studio 2017?
-
Has anyone ever tried compiling Qt 4.8.7 with Visual Studio 2017? Our code is still based on Qt 4.8.7, but we currently don't have time to upgrade to Qt 5.X yet. However, we would like to upgrade our compiler to VS2017...
I tried simply copying the
win32-msvc2015
mkspecs directory to a newwin32-msvc2017
, and tried usingQMAKESPEC=win32-msvc2017
, but it turns out that it is not that simple. From my investigations, I deduced that I also need to adapt and recompile theconfigure.exe
tool so that it supports VS2017, but up until now, I haven't succeeded in that yet.So my two questions are:
- Does anyone have experience/steps/links about compiling Qt 4.8.7 with VS2017?
- How does one recompile the configure tool which is under the tools directory in the 4.8.7 source tree?
-
Hi,
What exact error do you have ?
-
@SGaist I get
QMAKESPEC environment variable is set to "win32-msvc2017" which is not a supported platform
That error comes from
tools/configure/configureapp.cpp
and is due to the fact that the configure tool does not supportwin32-msvc2017
. I would like to modify the source code of the configure tool and rebuild it with support forwin32-msvc2017
, but I cannot get it to build yet... -
@Bart_Vandewoestyne Do you really need to build Qt 4.8.7 with VS2017?
This Qt version is quite old and for sure was never tested with VS2017. -
@Bart_Vandewoestyne said in Building Qt 4.8.7 with Visual Studio 2017?:
- How does one recompile the configure tool which is under the tools directory in the 4.8.7 source tree?
Rather than modifying the tools, it's probably easier to fool them into thinking that you're using MSVC 2015.
MSVC 2017 is supposedly compatible with MSVC 2015.
Try using the
win32-msvc2015
mkspec. If something fails, try modifying mkspecs/win32-msvc2015/qmake.conf by replacingQMAKE_COMPILER_DEFINES += _MSC_VER=1900 WIN32
with the appropriate version number (see https://blogs.msdn.microsoft.com/vcblog/2017/11/15/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/ )Disclaimer: I've never tried this myself. This is just an educated guess.
-
@JKSH said in Building Qt 4.8.7 with Visual Studio 2017?:
@Bart_Vandewoestyne said in Building Qt 4.8.7 with Visual Studio 2017?:
- How does one recompile the configure tool which is under the tools directory in the 4.8.7 source tree?
Rather than modifying the tools, it's probably easier to fool them into thinking that you're using MSVC 2015.
I can understand that reasoning, but for now I prefer to go for the long term solution that can also benefit the community. I really want to try to modify the source so that it compiles with VS2017. Maybe also as a kind of exercise and for the challenge of it :-) And if I get it working, of course I can share the patch with the community.
Here's my attempt so far: https://github.com/BartVandewoestyne/qt_4_8_7_with_vs2017_patch
It is unfinished work. As you can see from the patch, I don't think there are that much changes necessary to adapt theconfigure
tool andqmake
for VS2017. However, I still haven't succeeded to re-compile theconfigure
tool with my VS2017. I've found this link: https://wiki.qt.io/How_to_prevent_Qt_from_compiling_code_examples but i couldn't make it work.
Any help with that would be appreciated, so that we can see what the next hurdle to overtake is :-) -
@Bart_Vandewoestyne I think it would be better to ask on Qt developers mailing list.
Qt4 isn't maintained any-more, so I don't think there will be new Qt4 release including your changes. -
Hi Bart,
I wonder if you have managed to compile Q 4.8.7 with VS 2017, because I am also interested to. Whenever I try, I get a lot of errors. I also try your diff, but after applying it, and run configure.exe, it stops saying 'file not found', but it does not say what file is not found. Thanks
-
Hi @perdigao1,
The mailing list request also lead to
win32-msvc2015
mkspec, just as @JKSH recommended.So I guess that is worth a try.
Regards
-
Hey Bart,
if you're still interested in a solution. I've got it to work.
I have a patched version of Qt, including a recompiled configure.exe that will allow you to use the win32-msvc2017 makespec.
https://github.com/scharsig/Qt/tree/master/qt-4.8.7-vs2017
You are right, there are several things to be done to make Qt 4.8.7 compilable with VS2017.
1.) You need to patch the code (which you have), but that was required for VS2015 aswell. No changes there.
2.) You need to create the new makespec. Which is fairly easy, just copy the win32-msvc2015 folder and rename it. You can change the QMAKE_COMPILER_DEFINES macro to contain the 1914 version instead of 1900, but it is not really required.
3.) qmake won't compile as it is, you need to change the Makefile.win32 file which is in the QTDIR/qmake folder. It's the first line with all the '||' or statements. Add the "$(QMAKESPEC)" == "win32-msvc2017" line to it. Otherwise, you'll get the error that you're using an unsupported compiler for this Makefile during the configure step.
4.) The configure program. You are right to want to change it. Two changes are needed:
a.) configureapp.cpp:1380: Add the qmakeSpec.endsWith("-msvc2017") line to it, otherwise the if statement won't use the "Makefile.win32" makefile when compiling qmake and everything else will fail.
b.) To make configure compilable, you will need to add this line to its configure.pro file:
win32-msvc2017: DEFINES += _ALLOW_KEYWORD_MACROS
You can add it directly into the win32-msvc* block, since you're only using it for 2017.There's a bootstrapping problem of course. You need to create Makefiles for configure, but configure is the one that creates qmake.exe. My approach is to configure qt using the win32-msvc2015 makespec and let it create qmake. Then create the makefiles for configure, make sure I can compile it. It doesn't matter what you use to compile configure.exe. Now I can reconfigure the Qt build to use my win32-msvc2017 makespec and actually build the whole thing. I've tested it including the webkit, so I guess the worst is done ;).
It's not perfect yet. The makespec contains weird options (-FS) that give me warnings on my machine but that is easy to fix. The build step produces a couple of warnings here and there, but with Qt, I'm not sure they weren't there before.
Cheers
-
@Dariusz.Scharsig I had modified qt5.4.1 as what you said. But when compile qt with vs2017, cmd print error: File or path not found(make). So , is there any more files should I modify to let it compile successful?