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

Поделиться
HTML-код
  • Опубликовано: 3 фев 2025

Комментарии • 36

  • @JosepSubiranaOller
    @JosepSubiranaOller Год назад +3

    Excelent video, learned a lot! Thanks.

    • @KDABtv
      @KDABtv  Год назад

      Glad that you enjoyed the video!

  • @matpietrzak
    @matpietrzak Год назад +2

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

    • @KDABtv
      @KDABtv  Год назад

      Thank you for watching! :)

  • @theintjengineer
    @theintjengineer Год назад +1

    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

  • @CristianAdam
    @CristianAdam Год назад +2

    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.

    • @KDABtv
      @KDABtv  Год назад +1

      Hi Christian,
      Thanks for the tips. WSL, of course, gives you the overhead of the virtual machine that it is running in. An alternative for better development experience under Windows is the recently-released DevDrive: learn.microsoft.com/en-us/windows/dev-drive/ which has less filesystem hooks and uses higher-performance ReFS filesystem. Some of our employees reported significantly reduced compilation times with it.
      As for the problems with Qt Creator, stay tuned for the part 2 of this series where we'll show how to connect to your WSL environment from Visual Studio Code running on the host Windows OS.

    • @cyrilanisimov
      @cyrilanisimov 11 месяцев назад

      Earlier I used VcXsrv Windows X Server and export DISPLAY=my-host-address:0 in .bashrc. It looks like native Windows app (borders and window behavior).

  • @sunnychen5354
    @sunnychen5354 4 месяца назад

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

    • @KDABtv
      @KDABtv  4 месяца назад

      Hi there,
      That's the standard Windows 11 start menu. Linux applications like Qt Creator are dynamically added to the list of applications in the host Windows operating system start menu.

    • @sunnychen5354
      @sunnychen5354 4 месяца назад

      @@KDABtv i find it after restarting the computer several times.

  • @vendetta.02
    @vendetta.02 11 месяцев назад

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

  • @Kalyan16dev
    @Kalyan16dev Месяц назад

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

    • @KDABtv
      @KDABtv  13 дней назад

      Hi there,
      It may be that your WSL distribution is fairly old and doesn't have the latest SSL certificates. Could you please reply with the output of command lsb_release -a (executed in WSL terminal)? This will show us what your distribution version is.

    • @Kalyan16dev
      @Kalyan16dev 13 дней назад

      @KDABtv thank you. It's done. I have another doubt.. client asking to do on linux QT, but I'm going to propose to do with wsl ubuntu QT. Is there any problem after completing? The files can be compiled in pure linux before deployment?

  • @Никита-с9ч4т
    @Никита-с9ч4т 8 месяцев назад

    Thank you very much! Very good tutorial!

  • @tomislavdragusica6325
    @tomislavdragusica6325 7 месяцев назад

    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?

    • @KDABtv
      @KDABtv  6 месяцев назад +1

      Hey, Miłosz speaking here,
      Installing to ~/ should work fine. I just tried that with Qt 6.7.2 and it worked. Are you compiling from Qt Creator? If yes, could you go to Edit→Preferences, choose the "Kits" section, open "Qt Versions" tab and see what Qt versions do you have available? If you choose one of them, there should be a "qmake path:" below. Check if the path is correct. Perhaps you have some lingering old entry for Qt in /opt in your kit settings.
      By the way, I discovered that newer version of Qt (6.7.2) needs some additional packages (libxcb-cursor0 libglx-dev libgl1-mesa-dev) to compile and run Qt Widgets application. Make sure to install those if you have this new Qt version.

  • @johngrabner7429
    @johngrabner7429 7 месяцев назад

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

    • @KDABtv
      @KDABtv  6 месяцев назад +1

      Hi there,
      the link should work again now. We're sorry for the inconvenience.

  • @nagarajumukka3717
    @nagarajumukka3717 4 месяца назад

    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

    • @KDABtv
      @KDABtv  4 месяца назад

      Hey,
      could you paste the outputs of the following commands (run in WSL terminal):
      ldd /opt/Qt/6.5.3/gcc_64/plugins/platforms/libqxcb.so
      (replace the Qt version number with the one you've installed)
      and
      ldd /opt/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so

  • @tee-nw5vx
    @tee-nw5vx 8 месяцев назад

    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?

    • @KDABtv
      @KDABtv  8 месяцев назад +1

      Hey,
      could you paste the outputs of the following commands (run in WSL terminal):
      ldd /opt/Qt/6.5.3/gcc_64/plugins/platforms/libqxcb.so
      (replace the Qt version number with the one you've installed)
      and
      ldd /opt/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so

    • @maratfatkulov4993
      @maratfatkulov4993 4 дня назад

      @@KDABtv Hi! I also have this problem, but my opt folder is empty. This error happens before I even run my qt-installer script. How I can fix it?

  • @jimp313
    @jimp313 11 месяцев назад

    Good work! Like tutorials like this.

    • @KDABtv
      @KDABtv  11 месяцев назад

      Thank you very much! We're happy that you enjoy our videos! :)

  • @pkop4
    @pkop4 Год назад

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

    • @KDABtv
      @KDABtv  Год назад +1

      Hi,
      Not really. "apt upgrade" will update all currently installed packages on your system. If any of the subequently installed packages would require updates to their dependencies, it will happen automatically.

  • @cyrilanisimov
    @cyrilanisimov Год назад

    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.

    • @KDABtv
      @KDABtv  6 месяцев назад +1

      Hi,
      According to Microsoft documentation on WSL (learn.microsoft.com/en-us/windows/wsl/install#install-wsl-command) all the necessary features will be turned on automatically. And WSL2 is the default for quite some time already.

    • @cyrilanisimov
      @cyrilanisimov 6 месяцев назад

      @@KDABtv ah, cool

  • @serhiymalokhatko
    @serhiymalokhatko 11 месяцев назад

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

    • @KDABtv
      @KDABtv  6 месяцев назад +1

      Hi,
      The official installer already supports commandline-based installation, see: doc.qt.io/qt-6/get-and-install-qt-cli.html
      Also, there's another project that provides CLI Qt installer: github.com/miurahr/aqtinstall

  • @nagarajumukka3717
    @nagarajumukka3717 4 месяца назад

    This error I see when trying to install the installer file on WSL.
    Any suggestions on fixing this?
    $ uname -a
    Linux ABC1234 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    ~/Downloads$ sudo ./qt-online-installer-linux-x64-4.8.1.run
    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

    • @KDABtv
      @KDABtv  3 месяца назад

      Hi,
      please apply the same solution we mentioned in your previous comment below this video.