Debugging on Linux

If you have set up Qt VS Tools for cross-compilation on Linux, you can debug applications running on a Linux devices. First launch the application using gdbserver and then configure GDB to connect to the device and start a remote debugging session.

For this to work, the GDB installed in the WSL must support the target device architecture. A simple way to achieve this is to install gdb-multiarch. To ensure the Visual Studio uses the correct debugger, create a symbolic link from gdb to gdb-multiarch.

To set up the remote debugging session in Visual Studio, you must pass additional commands to GDB. Select Project > Properties > Configuration Properties > Debugging, and then select GDB Debugger in Debugger to launch. In Additional Debugger Commands, add the following commands:

target extended-remote <IP_address>:<port>
set remote exec-file <path_to_executable>

Before starting the remote debugging session, set the required environment variables and launch gdbserver on the device:

  • LD_LIBRARY_PATH specifies the path to the directory where Qt binaries are installed.
  • QT_QPA_PLATFORM specifies the platform plugin, such as EGLFS, LinuxFB, DirectFB, or Wayland.
  • QT_QPA_PLATFORM_PLUGIN_PATH specifies the path to the directory where the platform plugin is installed.
  • For the EGLFS platform, QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT specify the screen width and height in millimeters.
  • QML2_IMPORT_PATH specifies the path to the directory where QML modules are installed.

Press F5 to start the remote debugging session.

Remote QML Debugging

To debug Qt Quick applications on Linux devices, enable QML debugging and set up program arguments for starting a QML debugging session. Project > Properties > Configuration Properties > Debugging, and then select GDB Debugger in Debugger to launch. In Additional Debugger Commands, add the following command:

-qmljsdebugger=port:<port>,host:<IP_address>,block

© 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.