Qt VS Tools support cross-compilation of Qt projects by integrating Qt/MSBuild and the Linux development VS workload. This enables you to develop widget-based and Qt Quick applications that target both Windows and Linux, including embedded devices.

To develop Qt applications for Linux using Visual Studio:

  • Install the Desktop development with C++ and Linux development with C++ workloads.
  • Enable the Windows Subsystem for Linux (WSL) and install a Linux distribution.
  • Alternatively, create a connection to a remote Linux build server.
  • Register the cross-compiled Qt build that resides in a WSL instance or the remote build server.

To add a Qt version for cross-compilation:

  1. Select Extensions > Qt VS Tools > Qt Versions > to add a new Qt version.
  2. In the Version field, enter a name for the Qt version. If you add the path to Qt first, this field is filled automatically.
  3. In Host, select Linux WSL or Linux SSH.
  4. In the Path field, enter the path to the Qt installation.
  5. In the Compiler field, enter the cross-compiler to use. The default value is g++.

Compiling on WSL

Using a WSL instance to run the cross-compiler is faster than using an SSH connection to a build host. When using SSH, MSBuild must first upload the source files to the remote host, whereas WSL mounts local drives in /mnt, making file access instantaneous.

MSBuild assumes that paths specified in options are local paths and maps them to corresponding Linux paths rooted on /mnt. For example:

C:\include\foolib maps to /mnt/c/include/foolib

Using absolute Linux paths as value of Extensions > Qt VS Tools > Options > Qt/MSBuild can lead to incorrect mappings. For example, /home/user/raspi maps to /mnt/home/user/raspi.

To avoid this issue, create symbolic links in /mnt to other top-level directories in the WSL instance file system.

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.