Subnavigation

Cross Platform Development with Qt and Visual Studio

              

In an upcoming release of the Qt Visual Studio Tools, scheduled for this summer, we plan to add support for Visual Studio Linux projects. Since the introduction of the C++ Linux workload, users have had the possibility of working on Linux development in Visual Studio. This feature is of potential interest to Qt developers, given the cross-platform nature of Qt itself, which is why we are now planning to add support for it in the Qt VS Tools extension.

As to how the cross compilation actually works, when building Linux projects in VS, the build process and overall orchestration will rely on either MSBuild or CMake, in the same way as traditional Win32 projects. The build tools themselves will then run in a compilation server, accessible through SSH. For MSBuild projects, Visual Studio allows selecting either gcc or clang as the C++ compiler.

C++ Linux workload selection in the VS Installer

Our plan for adding support for Linux projects is to use the features included in the VS Linux development workload to expand the existing Qt/MSBuild targets. The goal is to be able to build and run Qt-enabled MSBuild projects, both natively for Windows or cross-built for Linux.

As the first step towards that end, and as a proof of concept, we manually converted a simple Qt example (wiggly) to an MSBuild project that targets both Windows and Linux. Pressing F5 will build the project for the selected target and then launch a debug session, either locally for a Windows build or via gdbserver in case of Linux.

Building and debugging in both Windows and Linux

This exercise demonstrated that it's possible to use the Visual Studio IDE to develop, build and even debug multi-platform Qt applications. Therefore, regardless of the target platform, the Qt VS Tools extension should be able to seamlessly assist with the setup and usage of Qt tools in MSBuild projects. We've also learned that the changes to the Qt/MSBuild targets, required for supporting both native and cross-platform builds, will mostly focus on the way the Qt tools are invoked. Most (if not all) of the logic that supports the integration of Qt with MSBuild will remain valid for Linux.

In this post, we've covered the case where VS is used to target a Linux host. However, given that the VS Linux workload requires only an SSH-accessible GNU toolchain, it's possible to use a cross-compiler toolchain instead of the host one. Conceivably, it should be possible to use VS as an alternative IDE for developing with Qt for MCUs. We'll explore this scenario in another blog post.

Thank you for reading and for your interest in Qt and the VS Tools extension. Please leave a comment below if you believe (or not) that this topic is relevant, or if you have any questions or suggestions.


Blog Topics:

Comments