Qbs setting target machine type

240 Views Asked by At

I'm trying to build Qbs example collidingmice on Windows 10 x64 and got the following error message:

Qt5Cored.lib(Qt5Cored.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'

I tried setting the following in the collidingmice.qbs

qbs.architecture : "x64"

and got the message

'x64' differs from the architecture produced by this compiler (x86)

I then tried

qbs.architecture : "x86_64"

which gives the error message;

'x86_64' differs from the architecture produced by this compiler (x86)

I then tried

qbs.architecture : "x86"

which gives the error message;

Qt5Cored.lib(Qt5Cored.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'

Is there a way to set target machine type e.g. to 'x86' or 'x64' in Qbs?

2

There are 2 best solutions below

2
On BEST ANSWER

My guess is that you are using an x86 compiler and an x64 Qt, which will not work. How did you set up your profile?

0
On

Here's how I fixed the same issue when building an application using the Qbs build system ("Tiled", the game tilemap editor). In my case I am using the Visual Studio 2019 x64 toolchain.

NOTE: This answer assumes that Qt and Qbs are in your PATH.

  1. Open the command prompt
  2. Run "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 to initialize VS2019 environment variables in your command prompt.
  3. cd to the directory where your .qbs project lives.
cd myproject
  1. Create a new shadow build directory for your build and cd into it.
mkdir build-myproject
cd build-myproject
  1. run qbs setup-toolchains --detect which should find your VS2019 environments.
  2. run qbs setup-qt --detect which should find your Qt environment (assuming you added to PATH).
  3. run qbs config --list profiles to show the detected toolchain profiles.

Example:

qbs config --list profiles
profiles.MSVC2019-x64.cpp.compilerVersion: "19.25.28614"
profiles.MSVC2019-x64.cpp.toolchainInstallPath: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64"
profiles.MSVC2019-x64.qbs.architecture: "x86_64"
profiles.MSVC2019-x64.qbs.targetPlatform: "windows"
profiles.MSVC2019-x64.qbs.toolchainType: "msvc"
...
  1. The MSVC2019 x64 profile is named "MSVC2019-x64". Now specify that via qbs property when building your application like so:
qbs build -f ..\MyAwesomeProject.qbs profile:MSVC2019-x64

Building as x86 can be accomplished in a similar manner, as long as an x86 build of Qt is available. Running the vcvarsall.bat batch file with x86 will set up your command prompt to use the VS x86 environment variables.