{"id":1067,"date":"2015-09-28T21:45:05","date_gmt":"2015-09-29T04:45:05","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=1067"},"modified":"2019-06-04T13:47:58","modified_gmt":"2019-06-04T20:47:58","slug":"cross-compiling-qt-5-5-for-beaglebone-debian","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/beaglebone\/qt5\/cross-compile\/","title":{"rendered":"Cross-compiling Qt 5.5 for Beaglebone-Debian"},"content":{"rendered":"<p>This tutorial shows how to cross-compile the Qt 5.5 framework for Beaglebone-Debian. We will build the X11-based version of Qt for the Beaglebone Black board.<\/p>\n<p><strong>Warning:<\/strong> Modern Beaglebone Debian distributions include a pre-built version of Qt that can be used by VisualGDB out-of-the-box. Follow <a href=\"https:\/\/visualgdb.com\/tutorials\/beaglebone\/qt5\/app\/\">this tutorial<\/a> to create a cross-compiled Qt5 app based on the pre-built Qt package. The rest of this tutorial demonstrates building of the Qt framework from scratch that can be useful if you need specific Qt configuration that is different from the default package.<\/p>\n<ol>\n<li>Download an SD card image to your Beaglebone and get a matching <a href=\"http:\/\/gnutoolchains.com\/beaglebone\/\">cross-toolchain<\/a>:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/toolchain.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1068\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/toolchain.png\" alt=\"toolchain\" width=\"747\" height=\"412\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/toolchain.png 747w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/toolchain-300x165.png 300w\" sizes=\"(max-width: 747px) 100vw, 747px\" \/><\/a><\/li>\n<li>Download and install a MinGW toolchain that will be used to build the Windows-side build tools like Qmake:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-mingw.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-776\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-mingw.png\" alt=\"02-mingw\" width=\"747\" height=\"412\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-mingw.png 747w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-mingw-300x165.png 300w\" sizes=\"(max-width: 747px) 100vw, 747px\" \/><\/a><\/li>\n<li>Download and install<span class=\"Apple-converted-space\">\u00a0<\/span><a href=\"https:\/\/www.python.org\/downloads\/\">Python 2.7 for Windows<\/a><span class=\"Apple-converted-space\">\u00a0<\/span>and ensure that its directory is added to PATH.<\/li>\n<li>Download the Qt source package (e.g.<span class=\"Apple-converted-space\">\u00a0<\/span><a href=\"http:\/\/download.qt.io\/archive\/qt\/5.5\/5.5.0\/single\/qt-everywhere-opensource-src-5.5.0.tar.xz\">qt-everywhere-opensource-src-5.5.0.tar.xz<\/a>) from the<span class=\"Apple-converted-space\">\u00a0<\/span><a href=\"http:\/\/download.qt.io\/archive\/qt\/\">Qt Archive<\/a>.<\/li>\n<li>If you installed additional packages to your Beaglebone, you will need to resynchronize the sysroot with the toolchain to ensure that the toolchain has all the headers and libraries from your Beaglebone. Start the<span class=\"Apple-converted-space\">\u00a0<\/span><strong>UpdateSysroot.bat<\/strong><span class=\"Apple-converted-space\">\u00a0<\/span>file from the &lt;sysgcc&gt;\\Beaglebone\\TOOLS folder and synchronize the suggested directories.<\/li>\n<li>Launch the msys shell from the MinGW toolchain by running<strong>&lt;sysgcc&gt;\\MinGW32\\msys\\1.0\\msys.bat<\/strong>:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-shell.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-778\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-shell.png\" alt=\"04-shell\" width=\"677\" height=\"342\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-shell.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-shell-300x152.png 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><\/li>\n<li>Go to the directory containing the archive with the Qt source and extract it by running tar xf &lt;archive name&gt;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-unpack.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-779\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-unpack.png\" alt=\"05-unpack\" width=\"677\" height=\"342\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-unpack.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-unpack-300x152.png 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><\/li>\n<li>Ensure that the directories containing the MinGW gcc compiler and the Beaglebone cross-compiler are added to PATH. If not, add them manually:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/paths.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1069\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/paths.png\" alt=\"paths\" width=\"677\" height=\"342\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/paths.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/paths-300x152.png 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a>Ensure the the default &#8216;make&#8217; executable is the one from the MinGW build folder. If not, add the \/bin folder to the beginning of PATH.<\/li>\n<li>Now we will edit the device configuration file to fix the build and enable X11 as the default GUI platform for Qt. Comment out the &#8220;-mfloat-abi&#8221; setting and change QT_QPA_DEFAULT_PLATFORM to xcb:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/fp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1070\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/fp.png\" alt=\"fp\" width=\"811\" height=\"568\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/fp.png 811w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/fp-300x210.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/fp-130x90.png 130w\" sizes=\"(max-width: 811px) 100vw, 811px\" \/><\/a><\/li>\n<li>Now we are ready to build Qt. Due to a bug in the Qmake build script, we will need to build it in 2 steps: first we will build a Qmake for Windows and then we\u2019ll build the actual Qt binaries. First we will modify the win32-g++ platform definition to prevent MinGW from excluding some functions that Qt relies upon. Open<span class=\"Apple-converted-space\">\u00a0<\/span><strong>the\u00a0qt-everywhere-opensource-src-5.5.0\\qtbase\\mkspecs\\win32-g++\\qmake.conf<\/strong><span class=\"Apple-converted-space\">\u00a0<\/span>file and add<span class=\"Apple-converted-space\">\u00a0<\/span><strong>-U__STRICT_ANSI__<\/strong><span class=\"Apple-converted-space\">\u00a0<\/span>to CXXFLAGS:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06a-strictansi.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-782\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06a-strictansi.png\" alt=\"06a-strictansi\" width=\"626\" height=\"426\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06a-strictansi.png 626w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06a-strictansi-300x204.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><\/li>\n<li>Now we can build the Windows tools. Create a directory (e.g. qt-build) and run the configuration script from there:\n<pre class=\"\">mkdir qt-build\r\ncd qt-build\r\n..\/qt-everywhere-opensource-src-5.5.0\/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -device linux-beagleboard-g++ -sysroot C:\/SysGCC\/Beaglebone\/arm-linux-gnueabihf\/sysroot -prefix \/usr\/local\/qt5<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1071\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/build.png\" alt=\"build\" width=\"677\" height=\"570\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/build.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/build-300x253.png 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><\/li>\n<li>Eventually the build should fail complaining about the errors to process specs for the Beaglebone device. This is normal as long as qmake.exe got built. Check this by running \u201cqtbase\/bin\/qmake -v\u201d:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/qmake.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1072\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/qmake.png\" alt=\"qmake\" width=\"677\" height=\"354\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/qmake.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/qmake-300x157.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/qmake-390x205.png 390w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a><\/li>\n<li>Now we can build the rest of the Qt framework. First of all open the<span class=\"Apple-converted-space\">\u00a0<\/span><strong>qtbase\\configure<\/strong><span class=\"Apple-converted-space\">\u00a0<\/span>file and replace the condition before the \u201cCreating qmake line\u201d with this one:\n<pre class=\"\">if [ '!' -f \"$outpath\/bin\/qmake.exe\" ]; then<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-configure.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-787\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-configure.png\" alt=\"10-configure\" width=\"626\" height=\"426\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-configure.png 626w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-configure-300x204.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><\/li>\n<li>Start the configure script again, this time adding the following argument to the end of the previous command line:\n<pre class=\"\">-device-option CROSS_COMPILE=C:\/SysGCC\/Beaglebone\/bin\/arm-linux-gnueabihf- -qt-xcb<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/configured.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1073\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/configured.png\" alt=\"configured\" width=\"677\" height=\"810\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/configured.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/configured-251x300.png 251w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a>The -device-option is required when using the device specification, however if you specify it while building Qmake, the Qt build system will try to use the cross-compiler to build the Windows Qmake executable that will obviously fail.<\/li>\n<li>Once the configure script reports that the configuration is complete, run the \u201cmake &amp;&amp; make install\u201d command to build the entire Qt framework and install it into the cross-compiler directory. The framework is huge, so the build process might take several hours to complete, even on a fast machine.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/instdone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1074\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/instdone.png\" alt=\"instdone\" width=\"677\" height=\"342\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/instdone.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/instdone-300x152.png 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a>Warning: do not run \u201cmake install\u201d before \u201cmake\u201d succeeds as it would fail leaving the build directory in a partially built state failing further builds until the entire directory is deleted and re-created.<\/li>\n<li>Open SmarTTY (a portable version can be found in &lt;SysGCC&gt;\\Beaglebone\\TOOLS\\PortableSmartty) and connect to your Beaglebone. Then run the following commands to create the \/usr\/local\/qt5 folder and make it writable to the current user:\n<pre class=\"\">cd \/usr\/local\r\nsudo mkdir qt5\r\nsudo chown pi qt5<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/chmod.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1075\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/chmod.png\" alt=\"chmod\" width=\"653\" height=\"360\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/chmod.png 653w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/chmod-300x165.png 300w\" sizes=\"(max-width: 653px) 100vw, 653px\" \/><\/a><\/li>\n<li>Then select SCP-&gt;Upload directory and upload the &lt;sysroot&gt;\\usr\\local\\qt5 directory to \/usr\/local\/qt5:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/upload.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1076\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/upload.png\" alt=\"upload\" width=\"588\" height=\"181\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/upload.png 588w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/upload-300x92.png 300w\" sizes=\"(max-width: 588px) 100vw, 588px\" \/><\/a><\/li>\n<li>Go to the<strong> \/usr\/local\/qt5\/examples\/widgets\/dialogs\/classwizard<\/strong> directory and run .\/classwizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classw.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1082\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classw.png\" alt=\"classw\" width=\"857\" height=\"342\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classw.png 857w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classw-300x120.png 300w\" sizes=\"(max-width: 857px) 100vw, 857px\" \/><\/a><\/li>\n<li>If Qt complains about missing QT_XKB_CONFIG_ROOT variable and the keyboard does not work, you can define it by running the following command:\n<pre class=\"\">export QT_XKB_CONFIG_ROOT=\/usr\/share\/X11\/xkb<\/pre>\n<\/li>\n<li>Then the example will start normally (the QXcbConnection error can be ignored):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/xkb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1083\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/xkb.png\" alt=\"xkb\" width=\"799\" height=\"300\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/xkb.png 799w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/xkb-300x113.png 300w\" sizes=\"(max-width: 799px) 100vw, 799px\" \/><\/a><\/li>\n<li>You will see the Qt class wizard window forwarded from the remote machine:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classwin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1084\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classwin.png\" alt=\"classwin\" width=\"516\" height=\"465\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classwin.png 516w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/classwin-300x270.png 300w\" sizes=\"(max-width: 516px) 100vw, 516px\" \/><\/a>Follow <a href=\"http:\/\/visualgdb.com\/tutorials\/beaglebone\/qt5\/app\/\">this tutorial<\/a> to learn how to create Qt projects for Beaglebone-Debian with Visual Studio.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to cross-compile the Qt 5.5 framework for Beaglebone-Debian. We will build the X11-based version of Qt<\/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,72,33,46],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1067"}],"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=1067"}],"version-history":[{"count":9,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1067\/revisions"}],"predecessor-version":[{"id":4698,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1067\/revisions\/4698"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=1067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=1067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=1067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}