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.
- Or, create a connection to a remote Linux build server.
- Add the cross-compiled Qt build that resides in a WSL instance or the remote build server.
To add a Qt version for cross-compilation:
- Go to Extensions > Qt VS Tools > Qt Versions
- Select to add a new Qt version.
- In Version, enter a name for the Qt version. If you add the path to Qt first, this field is filled automatically.
- In Host, select Linux WSL or Linux SSH.
- In Path, enter the path to the Qt installation.
- In Compiler, enter the cross-compiler to use. The default value is g++.
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 wrong mappings. For example,
/home/user/raspi maps to
To avoid this issue, create symbolic links in
/mnt to other top-level directories in the WSL instance file system.
© 2023 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.