{"id":137,"date":"2014-02-04T17:39:31","date_gmt":"2014-02-04T17:39:31","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=137"},"modified":"2015-09-30T11:24:15","modified_gmt":"2015-09-30T18:24:15","slug":"beaglebone-qt-x11","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/beaglebone\/qt-x11\/","title":{"rendered":"Creating Qt Projects for Beaglebone with Visual Studio"},"content":{"rendered":"<p><strong>Warning: This tutorial explains how to create a basic Qt project for the Beaglebone Black board running Angstrom Linux that is deprecated. Follow <a href=\"http:\/\/visualgdb.com\/w\/tutorials\/cross-compiling-qt5-projects-for-beaglebone-debian\/\">this tutorial<\/a> for instructions on cross-compiling Qt5 applications for Beaglebone running Debian.<\/strong><\/p>\n<p>Before you begin ensure that you have installed <a href=\"\/download\/\">VisualGDB 4.1<\/a> or later.<\/p>\n<ol>\n<li>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 <a href=\"http:\/\/smartty.sysprogs.com\/\">SmarTTY<\/a>) and run the following commands:\n<pre>opkg update\r\nopkg install qt4-x11-free --force-depends\r\nopkg install libqtcore-dev libqtgui-dev<\/pre>\n<p>You might get some error messages during installation, however in most of the cases the installed Qt libraries will be still usable.<\/li>\n<li>Start Visual Studio and begin creating a new project with the VisualGDB Linux Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/01-prj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/01-prj.png\" alt=\"01-prj\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>On the first page of the wizard select a Qt-based application:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/02-qtprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/02-qtprj.png\" alt=\"02-qtprj\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>As compiling the code on the Beaglebone board would take a lot of time, we will use a cross-compiler. Select &#8220;Beaglebone&#8221; from the toolchain list and specify connection settings for your board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/03-board.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/03-board.png\" alt=\"03-board\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>If you have installed new packages on the board since the last synchronization, click &#8220;Synchroinze headers and libraries&#8221; to have the latest files from the board copied to the cross-compiler toolchain. VisualGDB will synchronize them automatically:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/04-sync.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/04-sync.png\" alt=\"04-sync\" width=\"484\" height=\"230\" \/><\/a><\/li>\n<li>Once you click Finish, VisualGDB will test all necessary tools and prepare the toolchain for building your application:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/05-prepare.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/05-prepare.png\" alt=\"05-prepare\" width=\"484\" height=\"374\" \/><\/a><\/li>\n<li>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 &#8220;no&#8221;, as the files you have installed in step 1 are sufficient for building projects with the cross-compiler.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/06-qtauto.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/06-qtauto.png\" alt=\"06-qtauto\" width=\"459\" height=\"184\" \/><\/a><\/li>\n<li>Once your project is generated, you can build it. Visual Studio will show an error indicating that QMainWindow file is not found:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/07-error.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/07-error.png\" alt=\"07-error\" width=\"698\" height=\"614\" \/><\/a><\/li>\n<li>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):<br \/>\n<table class=\"neat_table\">\n<tbody>\n<tr>\n<td style=\"height: 20px;\">OE_QMAKE_INCDIR_QT<\/td>\n<td style=\"height: 20px;\">&lt;toolchain&gt;\\arm-angstrom-linux-gnueabi\\sysroot\\usr\\include\\qt4<\/td>\n<\/tr>\n<tr>\n<td>OE_QMAKE_LIBDIR_QT<\/td>\n<td>&lt;toolchain&gt;\\arm-angstrom-linux-gnueabi\\sysroot\\usr\\lib<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/08-dirs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/08-dirs.png\" alt=\"08-dirs\" width=\"700\" height=\"637\" \/><\/a><\/li>\n<li>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:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/09-messagebox.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/09-messagebox.png\" alt=\"09-messagebox\" width=\"698\" height=\"612\" \/><\/a><\/li>\n<li>Finally you can resolve IntelliSense errors by adding the Qt include directories to the IntelliSense Include Directory list in VisualGDB Project Properties:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/10-intellisense.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/10-intellisense.png\" alt=\"10-intellisense\" width=\"700\" height=\"586\" \/><\/a><\/li>\n<li>Once you apply those settings, IntelliSense will work just like for normal Windows projects:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/11-arghint.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/beaglebone\/qt-x11\/11-arghint.png\" alt=\"11-arghint\" width=\"698\" height=\"611\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: This tutorial explains how to create a basic Qt project for the Beaglebone Black board running Angstrom Linux that<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[34,33,46],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/137"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":1112,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/137\/revisions\/1112"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}