Using Windows Subsystem for Linux (WSL) for C++ and Qt Application Development (Part 1)

preview_player
Показать описание
If you're a C++ developer, with or without Qt, on Windows, and sometimes need to test your application on Linux, there's an easy way to build and test it without rebooting now. Microsoft introduced Windows Subsystem for Linux. A mechanism to run a lightweight virtual machine with a Linux distribution with just a few clicks with elegant integration with the host OS. I'll show you how to install it and configure for working with C++ and Qt applications.

Here are the steps to follow to install:

* Development tools installation: sudo apt install build-essential gdb cmake ninja-build git
* Packages for running Qt installer: sudo apt install libfontconfig1 libxcb-glx0 libx11-xcb1 libxcb-icccm4 libxcb-image0  libxcb-keysyms1 libxcb-randr0 libxcb-render-util0  libxcb-sync1 libxcb-xfixes0  libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0 libgl1 libegl1 libxcb-shape0 libxcb-cursor0 libglx-dev libgl1-mesa-dev
* Packages for compiling the Qt Widgets application: sudo apt install libgl-dev libxcb-cursor0 libwayland-cursor0 libwayland-egl1

About the host:
This video is presented by Miłosz Kosobucki, a software engineer in KDAB. He has been working professionally with C++ and Qt for more than 10 years across a range of industries in areas like game development, embedded systems and desktop applications.

About KDAB:

KDAB experts regularly take time out to deliver KDAB’s world class training, in-house or at open enrollment courses around the world. We are the market leaders for training in Qt, OpenGL, and C++.

Комментарии
Автор

Excelent video, learned a lot! Thanks.

JosepSubiranaOller
Автор

This is a good intro to wsl for Qt ethusiast. Nice!

matpietrzak
Автор

8:35 what app do u use to find qt creator in wsl?❤

sunnychen
Автор

I'm getting SSL HandShake failed error while setup of QT open source. How to resolve it?

Kalyandev
Автор

If you have to use Windows and work with Qt cross-platform code, it's better to use WSL, you get a faster compiler, no antivirus that slows down things, a faster debugger, etc. Heck you can even cross-compile from WSL using mingw-w64 to have Windows binaries.

But there is one disadvantage, it looks like an eye-sore and doesn't look like a native application. If you do a websearch after "WSLg and Qt Creator" you will find a way to configure Qt Creator on WSLg running on Linux which looks almost the same as the windows Qt Creator version! It's not easy, but it can be done.

CristianAdam
Автор

Yeah, nice, but I'd need to use a newer version of the compiler chain, because of some C++20/23 features Iʼm using and that these old versions don't yet support. So, basically using MSVC the most [or Clang on my Linux physical machine]


Also, the only thing stopping me from using Qt more is the fact Qt doesn't play nice with C++20 Modules and I can't really live without Modules anymore.

Nevertheless, nice video, Milo.
It's always good to see stuff that tries to enhance developer experience. Being able to develop and try Linux Apps from Windows is one of them.

Cheers

theintjengineer
Автор

Thank you very much! Very good tutorial!

Никита-счт
Автор

Good work! Like tutorials like this.

jimp
Автор

The link to the example code no longer works. And I can't find it on github either. Is it still available?

johngrabner
Автор

How to fix this?

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, xcb.

Aborted

nagarajumukka
Автор

@KDAB We really need a command line Qt Installer, please, make it.

serhiymalokhatko
Автор

qt.qpa.xcb: could not connect to display 172.17.64.1:0.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, xcb.

Aborted - i am getting this error. how to fix this?

tee-nwvx
Автор

In the beginning a very important topic was skipped - to turn on "virtualization" and "windows subsystem for Linux" in "Windows Features" dialog. Also I'm not sure but WSL may be not version 2 by default and need to set it either.

cyrilanisimov
Автор

you will generally have a better linux experience on bare metal or on a VM y'all.

vendetta.
Автор

is it necessary to run sudo apt upgrade after sudo apt update before installing new packages?

pkop
Автор

Do you know if i can install it somewhere other than /opt/Qt, because I tried installing it inside ~ and my CMAKE_PREFIX_PATH keeps setting to /opt/Qt/6.5.3/gcc_64 even though there is no Qt directory there?

tomislavdragusica
Автор

This error I see when trying to install the installer file on WSL.
Any suggestions on fixing this?

$ uname -a
Linux ABC1234 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux


~/Downloads$ sudo
MoTTY X11 proxy: No authorisation provided
qt.qpa.xcb: could not connect to display localhost:10.0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, xcb.

Aborted

nagarajumukka
visit shbcf.ru