I'm setting up a Docker container with Qt5 5.12.2 and I'm using a microsoft visual studio 15 compiler msvc2015_64 to build my project. However, I get a LNK1112: module machine type 'x64' conflicts with target machine type 'X86' error when building.
My first step is to build the Qt5 project with the same commands that are generated by Qt Creator:
C:\Qt\5.12.2\msvc2015_64\bin\qmake.exe C:\Users\userA\Desktop\Projects\myproj\app.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qtquickcompiler" && C:\Qt\Tools\QtCreator\bin\jom.exe qmake_all
C:\Qt\Tools\QtCreator\bin\jom.exe
This produces the machine type conflict error.
I have tried to add the following paths to my %path% env variable:
C:\Windows\System32
C:\Qt\5.12.2\msvc2015_64\bin
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
Already in my path env variable:
C:\Program Files (x86)\Windows Kits\8.1\bin\x86
C:\Program Files (x86)\Windows Kits\8.1\Windows Perormance Toolkit\
I have also tried to run the .bat files inside Microsoft Visual Studio 14.0:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat
Output of running the .bat file:
ERROR: Cannot determine the location of the VS Common Tools folder
I've looked this error up and I think the suggestion was to add the C:\Windows\System32
to the env variable %path%. I tried that but same error.
My Dockerfile:
FROM microsoft/windowsservercore:10.0.14393.1884
LABEL Description="Windows Server Core development environment for Qbs with Qt 5.12.2, Chocolatey and various dependencies for testing Qbs modules and functionality"
# Disable crash dialog for release-mode runtimes
RUN reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v Disabled /t REG_DWORD /d 1 /f
RUN reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d 1 /f
# Install Qt5 5.12.2
COPY qtifwsilent.qs C:\\qtifwsilent.qs
RUN powershell -NoProfile -ExecutionPolicy Bypass -Command \
$ErrorActionPreference = 'Stop'; \
$Wc = New-Object System.Net.WebClient ; \
$Wc.DownloadFile('http://download.qt.io/archive/qt/5.12/5.12.2/qt-opensource-windows-x86-5.12.2.exe', 'C:\qt.exe') ; \
Echo 'Downloaded qt-opensource-windows-x86-5.12.2.exe' ; \
$Env:QT_INSTALL_DIR = 'C:\\Qt' ; \
Start-Process C:\qt.exe -ArgumentList '--verbose --script C:/qtifwsilent.qs' -NoNewWindow -Wait ; \
Remove-Item C:\qt.exe -Force ; \
Remove-Item C:\qtifwsilent.qs -Force
ENV QTDIR C:\\Qt\\5.12.2\\msvc2015
ENV QTDIR64 C:\\Qt\\5.12.2\\msvc2015_64
RUN dir "%QTDIR64%" && dir "%QTDIR64%\bin"
# Install choco for psuedo package manager
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command \
$Env:chocolateyVersion = '0.10.8' ; \
$Env:chocolateyUseWindowsCompression = 'false' ; \
"iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN choco install -y python2 --version 2.7.14 && refreshenv && python --version && pip --version
RUN choco install -y qbs --version 1.9.1 && qbs --version
RUN choco install -y unzip --version 6.0 && unzip -v
RUN choco install -y visualcpp-build-tools --version 14.0.25420.1 && dir "%PROGRAMFILES(X86)%\Microsoft Visual C++ Build Tools"
# RUN choco install -y windows-sdk-10.1
# RUN choco install -y vcredist2008 --version 9.0.30729.6161
# RUN choco install -y vcredist2010
RUN choco install -y zip --version 3.0 && zip -v
# for building the documentation
RUN pip install beautifulsoup4 lxml
My qtifwsilent.qs to setup Qt5 has these components:
widget.deselectAll();
widget.selectComponent("qt.qt5.5122.win32_msvc2015");
widget.selectComponent("qt.qt5.5122.win64_msvc2015_64");
widget.selectComponent("qt.qt5.5122.qtcharts");
widget.selectComponent("qt.qt5.5122.qtdatavis3d");
widget.selectComponent("qt.qt5.5122.qtpurchasing");
widget.selectComponent("qt.qt5.5122.qtvirtualkeyboard");
widget.selectComponent("qt.qt5.5122.qtwebengine");
widget.selectComponent("qt.qt5.5122.qtnetworkauth");
widget.selectComponent("qt.qt5.5122.qtwebglplugin");
widget.selectComponent("qt.qt5.5122.qtscript");
widget.selectComponent("qt.tools.vcredist_msvc2015_x86");
widget.selectComponent("qt.tools.vcredist_msvc2015_x64");
I expect the project to build and generate an exe file.
I solved the problem so I'm just posting this here for future reference.
I had to update the Dockerfile to use a newer version of servercore as well as included required Windows kits. I also had to add several paths to my %path%
environment variable as shown below.
FROM mcr.microsoft.com/windows/servercore:ltsc2019
LABEL Description="Windows Server Core development environment for Qbs with Qt 5.12.2, Chocolatey and various dependencies for testing Qbs modules and functionality"
# Disable crash dialog for release-mode runtimes
RUN reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v Disabled /t REG_DWORD /d 1 /f
RUN reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d 1 /f
# Install Qt5 5.12.2
COPY qtifwsilent.qs C:\\qtifwsilent.qs
RUN powershell -NoProfile -ExecutionPolicy Bypass -Command \
$ErrorActionPreference = 'Stop'; \
$Wc = New-Object System.Net.WebClient ; \
$Wc.DownloadFile('http://download.qt.io/archive/qt/5.12/5.12.2/qt-opensource-windows-x86-5.12.2.exe', 'C:\qt.exe') ; \
Echo 'Downloaded qt-opensource-windows-x86-5.12.2.exe' ; \
$Env:QT_INSTALL_DIR = 'C:\\Qt' ; \
Start-Process C:\qt.exe -ArgumentList '--verbose --script C:/qtifwsilent.qs' -NoNewWindow -Wait ; \
Remove-Item C:\qt.exe -Force ; \
Remove-Item C:\qtifwsilent.qs -Force
ENV QTDIR C:\\Qt\\5.12.2\\msvc2015
ENV QTDIR64 C:\\Qt\\5.12.2\\msvc2015_64
RUN dir "%QTDIR64%" && dir "%QTDIR64%\bin"
# Install choco for psuedo package manager
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command \
$Env:chocolateyVersion = '0.10.14' ; \
$Env:chocolateyUseWindowsCompression = 'false' ; \
"iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN choco install -y python2 --version 2.7.14 && refreshenv && python --version && pip --version
RUN choco install -y qbs && qbs --version
RUN choco install -y unzip --version 6.0 && unzip -v
RUN choco install -y vcbuildtools -ia "/Full"
RUN choco install -y zip --version 3.0 && zip -v
RUN choco install -y cmake
RUN choco install -y windows-sdk-10.1
RUN choco install -y vcredist2008 --version 9.0.30729.6161
RUN choco install -y vcredist2010
# for building the documentation
RUN pip install beautifulsoup4 lxml
WORKDIR C:\\Users\\ContainerUser
For the environment path I used:
set path=%path%;"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC";C:\Qt\5.12.2\msvc2015_64\bin;"C:\Program Files (x86)\Windows Kits\10\bin\x64";"C:\Program Files (x86)\Windows Kits\8.1\bin\x64";C:\Qt\Tools\QtCreator\bin;
# Run this command to setup cl.exe
vcvarsall.bat x86_amd64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With