Cross-compile Qt 5.9.1 with MSVC 2017 x64 to x86 fails with linker error
-
But vs 2015 and vs 2017 are compatible ?
( for the first time)Are you sure you need to compile anything your self?
-
So far it seems, no matter what I do (tried passing -device-options, creating own mkspec for specific 32 bit platform, not to use the common msvc mkspec), after configuration my target architecture is set to x86_64 in qtbase/mkspecs/qconfig.pri. Also at the configuration phase when running config tests I get the message that target platform is x86_64.
What parameters shall I pass to the configure script to make it change? Has anyone tried this before?
-
Hi,
Did you try the
x86 Native Tools Command Prompt
?Also, how did you setup your build environment for the cross-compilation ?
-
Hi,
Thanks for the response!
I might have a conceptional misunderstanding. I have tried to set MSVC to x64 to x86 cross-compilation, thus ran vcvars.bat amd64_x86. Isn't the x86 Native Tool Command Prompt (i.e. vcvars.bat x86) for native compilation? Meaning that compile on a x86 host to a x86 target? I aim to build on a x64 host to a x86 machine, which means that all my build tools (e.g. qmake) shall be compiled with a native compiler (because I would run them on my 64-bit host), and all the libs I intend to deploy should be compiled to x86.
(So basically this is how I set my build environment for CC, running visual studio 2017's configuration script - vcvars.bat)
-
@jsulm Yes, that is true. However if I set my environment to a x86 toolchain (either amd64_x86 cross or even native x86) it would throw me the same error, meaning that the linker is targeting x64 for my build tools, such as qmake, while my libraries are compiled to x86. Therefore I get the architecture mismatch mentioned in my original post.
It seems that during the configuration of the Qt build it tries and discovers the host platform and sets the target for qmake automatically. Which is fine for me, as I would run qmake on x64 however I need my libraries built for x86 targets.
-
@SGaist
I was wrong before. I could properly compile with x86 native tools on x64. The problem was that after previous configurations the cache files were not cleaned properly and setup was stuck for x64 target.So the problem is worked around, however I still expect that it should be possible to compile with the x64_x86 cross tools. When I run the configure.bat script, the target architecture is listed as x64 (should be i386). Seems that no matter what I do, what flags I try to pass, this is unchanged. Seems that this value is somehow derived from the compiler itself and I am unable to set it to i386 instead of x64.
Does anybody know what flags are necessary to be passed to actually set the target architecture to i386?
Thank you for all your help,
Balazs -
Is it me or does it look like QTBUG-43457 ?
-
I have checked the source code of the qmakeevaluator and the changes are present in version 5.9.1, still it does not recognize the platform. Even if I try to hardcode to the qmake evaluator the following:
vars[ProKey("QMAKE_TARGET.arch")] = ProString("x86");
It does not change a thing, still tries to link qmake to x64.