Warning: This tutorial explains how to create a basic Qt project for the Beaglebone Black board running Angstrom Linux that is deprecated. Follow this tutorial for instructions on cross-compiling Qt5 applications for Beaglebone running Debian.
Before you begin ensure that you have installed VisualGDB 4.1 or later.
- First of all you need to install the X11 version of Qt on the Beaglebone device as it is not included in the default image. Connect to the device over SSH (e.g. using SmarTTY) and run the following commands:
123opkg updateopkg install qt4-x11-free --force-dependsopkg install libqtcore-dev libqtgui-dev
You might get some error messages during installation, however in most of the cases the installed Qt libraries will be still usable.
- Start Visual Studio and begin creating a new project with the VisualGDB Linux Project Wizard:
- On the first page of the wizard select a Qt-based application:
- As compiling the code on the Beaglebone board would take a lot of time, we will use a cross-compiler. Select “Beaglebone” from the toolchain list and specify connection settings for your board:
- If you have installed new packages on the board since the last synchronization, click “Synchroinze headers and libraries” to have the latest files from the board copied to the cross-compiler toolchain. VisualGDB will synchronize them automatically:
- Once you click Finish, VisualGDB will test all necessary tools and prepare the toolchain for building your application:
- The Qt package on Beaglebone is different from other Linux distributions, so VisualGDB will show a message that Qt is not found and offer installing it. Select “no”, as the files you have installed in step 1 are sufficient for building projects with the cross-compiler.
- Once your project is generated, you can build it. Visual Studio will show an error indicating that QMainWindow file is not found:
- This happens because the Qt for Beaglebone expects certain environment variables pointing to the locations of headers and libraries (see the generated Makefile for details). Right-click on your project in Solution Explorer, select VisualGDB Project Properties, go to the QMake page and add the following variables to the Make command (not the QMake one):
OE_QMAKE_INCDIR_QT <toolchain>\arm-angstrom-linux-gnueabi\sysroot\usr\include\qt4 OE_QMAKE_LIBDIR_QT <toolchain>\arm-angstrom-linux-gnueabi\sysroot\usr\lib
- Now you can build and debug your project. Press Ctrl-Shift-B to build it and F5 to start debugging. The X11 windows will be forwarded to your Windows machine using XMing:
- Finally you can resolve IntelliSense errors by adding the Qt include directories to the IntelliSense Include Directory list in VisualGDB Project Properties:
- Once you apply those settings, IntelliSense will work just like for normal Windows projects: