This tutorial shows how to cross-compile a simple Qt5 application for the Beaglebone Black board running Debian using Visual Studio and VisualGDB.
Note that as Qmake hardcodes the absolute paths to various files, unless you build cross-Qt yourself, you would need to use the exact path that was used when building CMake. You will also need to upload the Qt binary files from the toolchain to your Beaglebone using SmarTTY or any other SSH client:
- Start Visual Studio and open VisualGDB Linux project Wizard:
- On the first page select “Create a new project -> Application -> Use Qt”:
- Then select “Build the project locally”, choose your Beaglebone cross-toolchain and specify the connection settings for your Beaglebone. Then click “Configure Qt Settings”:
- Select “Use previously configured Qt tools” and point VisualGDB to the qmake binary (<toolchain>\arm-linux-gnueabihf\sysroot\usr\local\qt5\bin\qmake.exe) and the mkspecs directory (<toolchain>\arm-linux-gnueabihf\sysroot\usr\local\qt5\mkspecs\devices\linux-beagleboard-g++):
- Press “Finish” to generate the project. VisualGDB will ask whether to fix values for the environment variables that are different for interactive and command modes. Select “Fix value” and press OK:
- Build your project by pressing Ctrl-Shift-B:
- If IntelliSense fails to recognize the ui_MainWindow.h file, this happens because the directory containing it was not present when the project was created:Re-open the project and IntelliSense will start working.
- You can now press F5 to begin debugging. Qt will complain about the missing QT_XKB_CONFIG_ROOT and the keyboard won’t work for Qt applications:
- To fix this, open VisualGDB Project Properties and set the QT_XKB_CONFIG_ROOT environment variable to /usr/share/X11/xkb:
- Now the keyboard should work. Set a breakpoint in ButtonClicked() and click the button in the Qt window (or press the space key):
- The breakpoint will be triggered:
- Press F10 to step, or F5 to continue debugging. Once the msgBox.exec() gets called, you will see the Qt message box:
- You can also configure VisualGDB to show the remote Qt windows on the Beaglebone display directly:For this option to work, the same user that is used for SSH connection needs to be logged on to the Beaglebone.