{"id":1,"date":"2022-12-16T14:39:00","date_gmt":"2022-12-16T12:39:00","guid":{"rendered":"https:\/\/www.microfusion.org\/blog\/?p=1"},"modified":"2023-01-30T13:05:09","modified_gmt":"2023-01-30T11:05:09","slug":"cross-compile-and-deploy-qt-5-12-for-raspberry-pi-including-mariadb","status":"publish","type":"post","link":"https:\/\/www.microfusion.org\/blog\/cross-compile-and-deploy-qt-5-12-for-raspberry-pi-including-mariadb\/","title":{"rendered":"How to Setup Qt Cross-compile for Raspberry Pi including MariaDB"},"content":{"rendered":"\n<p>This guide will show you how to cross-compile Qt 5.12 for Raspberry Pi on your computer and install it on a Raspberry. Thus, thanks to Qt Creator, you can design and build Raspberry Pi apps on your computer and compile, deploy, run and debug them directly on the Raspberry Pi. <\/p>\n\n\n<div class=\"wp-block-aioseo-table-of-contents\"><ul><li><a class=\"aioseo-toc-item\" href=\"#aioseo-why-setup-cross-compile\">Why setup cross-compile ?<\/a><ul><li><a class=\"aioseo-toc-item\" href=\"#aioseo-things-we-will-need-to-setup-qt-and-raspberry-pi-cross-compiling\">Things we will need to setup Qt and Raspberry Pi Cross-Compiling<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-lets-get-started-on-the-raspberry-pi\">Lets get started on the Raspberry Pi<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-installing-the-development-libraries-on-the-raspberry-pi\">Installing the development libraries on the Raspberry Pi<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-prepare-the-target-folder-on-the-raspberry-pi\">Prepare the target folder on the Raspberry Pi<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-now-install-some-qt-libraries-we-will-need-later-including-mariadb\">Now install some Qt libraries we will need later including MariaDB<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-lets-move-over-to-the-development-linux-pc\">Lets move over to the development Linux PC<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-create-working-folder-and-setup-the-toolchain\">Create working folder and setup the toolchain<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-next-create-and-configure-a-sysroot\">Next, Create and configure a sysroot<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-download-qt-source\">Download Qt source<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-configure-qt-for-cross-compilation\">Configure Qt for cross compilation<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-compile-install-and-deploy-qt-on-the-development-pc\">Compile, install and deploy Qt on the development PC<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-setup-qt-creator-for-raspberry-pi-cross-compilation-on-the-pc\">Setup Qt Creator for Raspberry Pi cross compilation on the PC<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-setting-up-ssh-keys-for-qt-in-qt-5-14-1\">Setting up SSH Keys for Qt in Qt 5.14.1+<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-conclusion\">Conclusion<\/a><\/li><li><a class=\"aioseo-toc-item\" href=\"#aioseo-share-your-toughs-was-compiling-and-deploying-the-qt-tool-chain-easy-for-you\">Share your toughs, was compiling and deploying the Qt tool-chain easy for you ?<\/a><\/li><\/ul><\/li><\/ul><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"aioseo-why-setup-cross-compile\">Why setup cross-compile ?<\/h2>\n\n\n\n<p>Cross Compiling will benefit work flow and development speed overall, it will enable you to design and code applications on your PC and then compile and run and debug them directly on the Raspberry Pi.<\/p>\n\n\n\n<p>To setup a workable Qt C++ cross-compile environment with something like an IoT device such as a Raspberry Pi has always been very confusing and frustrating. This guide will help shed some light and clarity on how to go about setting up a workable Qt cross-compile environment using Linux and RaspOS. <\/p>\n\n\n\n<p>Qt 5.12 is the LTS (Long Term Support) version of the popular Qt framework. For those unfamiliar with Qt, <a href=\"https:\/\/www.qt.io\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Qt<\/a> is a rich framework which uses C++ with many ready-to-use multi-platform components in various areas such as multimedia, networking, connectivity, and graphics.<\/p>\n\n\n\n<p>Qt Creator is a powerful multi-platform integrated development environment (IDE) for building and deploying Qt apps, available for Linux, macOS, and Windows.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-things-we-will-need-to-setup-qt-and-raspberry-pi-cross-compiling\">Things we will need to setup Qt and Raspberry Pi Cross-Compiling<\/h4>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-7505880210632883\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7505880210632883\" data-ad-slot=\"6291301981\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p><\/p>\n\n\n\n<p>This step-by-step guide is for Raspberry Pi 3 Model B and Qt 5.12 Branch, but these steps should be similar for newer Qt releases and other Raspberry Pi board versions. <\/p>\n\n\n\n<p>We will be using Linux Mint for out Desktop operating system.<\/p>\n\n\n\n<p>But this guide should work with most major Linux distributions: Ubuntu, Debian, etc.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.raspberrypi.com\/software\/operating-systems\/\" target=\"_blank\" rel=\"noopener nofollow\" title=\"\">Raspberry Pi OS<\/a> is Raspbian Buster and works with any version (Raspbian Stretch are also supported). Again, the tutorial steps should be fairly similar for other configurations.<\/p>\n\n\n\n<p>You will also need a Raspberry Pi Model B+ or better. <\/p>\n\n\n\n<p>A SD class 10 SD card with Raspbian (RaspOS) operating system installed and ready to go. <\/p>\n\n\n\n<p>And both your Computer and the Raspberry Pi connected to the same network.<\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Note:<\/mark><\/strong> This tutorial works for Qt 5.12 and 5.12.2 to 5.12.5 (but not for 5.12.1 due to some bugs). For Qt 5.12.2 to 5.12.5, you need to set the <strong><em>-device argument<\/em><\/strong> in your build config file to <strong>linux-rasp-pi-g++<\/strong> instead of <strong>linux-rasp-pi3-g++<\/strong>. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-lets-get-started-on-the-raspberry-pi\">Lets get started on the Raspberry Pi<\/h4>\n\n\n\n<p>Lets check and make sure that the latest firmware in in use on the Raspberry Pi or install it and reboot the system. Execute the following command in the Raspberry Pi command-line interface (Terminal) for updating the firmware.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>sudo rpi-update\nreboot<\/code><\/pre>\n\n\n\n<p>Next make sure that you have activated the Secure Shell (SSH) protocol in Raspbian (RaspOS). We will need it later to link and communicate between Qt Creator on your PC and the Raspberry Pi.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>sudo raspi-config<\/code><\/pre>\n\n\n\n<p>Select Interfacing Options, select ssh, choose yes and finish. See Below<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img fetchpriority=\"high\" decoding=\"async\" width=\"765\" height=\"425\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/raspi-config.webp\" alt=\"\" class=\"wp-image-16\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/raspi-config.webp 765w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/raspi-config-300x167.webp 300w\" sizes=\"(max-width: 765px) 100vw, 765px\" \/><figcaption class=\"wp-element-caption\">Raspi-Config Menu<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-installing-the-development-libraries-on-the-raspberry-pi\">Installing the development libraries on the Raspberry Pi<\/h4>\n\n\n\n<p>We need to install some development libraries, so the first thing to do is to allow the system to install source packages, for this you only have to <strong>uncomment <\/strong>the <strong>deb-src<\/strong> line in the \/etc\/apt\/sources.list file, which configures the system repositories. Use your favorite text editor for this, we are using nano in this example.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>sudo nano \/etc\/apt\/sources.list<\/code><\/pre>\n\n\n\n<p>Then uncomment by remove &#8220;#&#8221; in front of the deb and <strong>deb-src<\/strong>. Save the file and exit. <\/p>\n\n\n\n<p>The next step is to update and install the required development packages.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>sudo apt-get update\nsudo apt-get build-dep qt4-x11\nsudo apt-get build-dep libqt5gui5\nsudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-prepare-the-target-folder-on-the-raspberry-pi\">Prepare the target folder on the Raspberry Pi<\/h4>\n\n\n\n<p>Create a folder on the Raspberry Pi for the <strong>pi<\/strong> user. This folder (<strong>\/usr\/local\/qt5pi<\/strong>) will be used to deploy Qt from our computer to the Raspberry Pi.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>sudo mkdir \/usr\/local\/qt5pi\nsudo chown pi:pi \/usr\/local\/qt5pi<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-now-install-some-qt-libraries-we-will-need-later-including-mariadb\">Now install some Qt libraries we will need later including MariaDB<\/h4>\n\n\n\n<p>On the raspberry Pi run the following command to install the libraries<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>sudo apt install mariadb-client mariadb-common mysql-common libmariadb-dev-compat libmariadbclient-dev libqt5sql5-mysql libqt5sql5 libqt5sql5-sqlite\n<\/code><\/pre>\n\n\n\n<p>The <strong>libmariadb-dev-compat<\/strong> package will create all the links necessary for compatibility between mariadb and mysql. Then, when you call to qt configure script you must indicate the path of the mysql (mariadb) libraries.<\/p>\n\n\n\n<p>Exit the Raspberry Pi SSH session.<\/p>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-7505880210632883\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7505880210632883\" data-ad-slot=\"6291301981\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<div style=\"height:32px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-lets-move-over-to-the-development-linux-pc\">Lets move over to the development Linux PC<\/h4>\n\n\n\n<p>For now we are done on the raspberry Pi, its time to move over to the PC you will be using to develop on. A few things need to happen here to make the cross compile environment work between the Raspberry Pi and Qt.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-create-working-folder-and-setup-the-toolchain\">Create working folder and setup the toolchain<\/h4>\n\n\n\n<p>On your Linux development PC, create a folder in home folder and download the toolchain. For this guide we will be creating a folder called <strong>raspi<\/strong> in the home directorty<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>mkdir ~\/raspi\ncd ~\/raspi\ngit clone https:\/\/github.com\/raspberrypi\/tools<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-next-create-and-configure-a-sysroot\">Next, Create and configure a sysroot<\/h4>\n\n\n\n<p>A <strong>sysroot<\/strong> is a directory structure that includes all the folders needed to run a particular system. We are creating a new sysroot for Raspberry Pi cross compilation on our development computer. Not on the Pi<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>mkdir sysroot sysroot\/usr sysroot\/opt<\/code><\/pre>\n\n\n\n<p>This is done inside of the <strong>raspi<\/strong> folder<\/p>\n\n\n\n<p>We can use <strong>rsync<\/strong> to synchronize our computer&#8217;s <strong>sysroot<\/strong> and the Raspberry Pi. So, if we make changes in our computer&#8217;s sysroot, they can be easily be transferred to our Raspberry Pi, <\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Note:<\/mark> raspberrypi_ip<\/strong> is the <strong>IP address<\/strong> of your Raspberry Pi on the local network, it&#8217;s easier to just use the IP address here.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>rsync -avz pi@raspberrypi_ip:\/lib sysroot\nrsync -avz pi@raspberrypi_ip:\/usr\/include sysroot\/usr\nrsync -avz pi@raspberrypi_ip:\/usr\/lib sysroot\/usr\nrsync -avz pi@raspberrypi_ip:\/opt\/vc sysroot\/opt<\/code><\/pre>\n\n\n\n<p>Next, we need to adjust our symbolic links in sysroot to be relative since this folder structure is on both our development computer and the Raspberry Pi.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>wget https:\/\/raw.githubusercontent.com\/riscv\/riscv-poky\/master\/scripts\/sysroot-relativelinks.py\n\nchmod +x sysroot-relativelinks.py\n.\/sysroot-relativelinks.py sysroot<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-download-qt-source\">Download Qt source <\/h4>\n\n\n\n<p>Download and untar Qt 5.12.5 or any other version you want to use.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>wget http:\/\/download.qt.io\/official_releases\/qt\/5.12\/5.12.5\/single\/ qt-everywhere-src-5.12.5.tar.xz\n\ntar xvf  qt-everywhere-src-5.12.5.tar.xz\ncd  qt-everywhere-src-5.12.5<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-configure-qt-for-cross-compilation\">Configure Qt for cross compilation<\/h4>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Note:<\/mark><\/strong> In the new Raspbian versions, EGL libraries have different names than those assumed in Qt configuration files, edit the <strong>.\/qtbase\/mkspecs\/devices\/linux-rasp-pi-g++\/qmake.conf<\/strong> file and substitute all references to <strong>-lEGL<\/strong> and <strong>-LGLESv2<\/strong> for <strong>-lbrcmEGL<\/strong> and <strong>-lbrcmGLESv2<\/strong>, respectively if needed.<\/p>\n\n\n\n<p>The <strong>linux-rasp-pi3-g++<\/strong> (<strong>Qt 5.12<\/strong>) or <strong>linux-rasp-pi-g++<\/strong> (<strong>Qt 5.12.2<\/strong> to <strong>Qt 5.12.5<\/strong>) folder applies to Raspberry Pi 3 version, if you have a different Raspberry Pi version check the list of compatible devices which can be found in&nbsp;<strong>.\/qtbase\/mkspecs\/devices<\/strong> and in the table below (summarized from the table in the tutorial to <a href=\"https:\/\/www.tal.org\/tutorials\/building-qt-512-raspberry-pi\" target=\"_blank\" rel=\"noreferrer noopener\">build Qt 5.12 for Raspbian directly on Raspberry Pi<\/a>).<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-ast-global-color-2-background-color has-background\"><tbody><tr><td><strong>Version<\/strong><\/td><td><strong>Configure option<\/strong><\/td><td><strong>Architecture<\/strong><\/td><td><strong>Remarks<\/strong><\/td><\/tr><tr><td>&nbsp;&nbsp;Raspberry Pi 3<br>&nbsp;&nbsp;<strong>(not working for<\/strong><br>&nbsp;&nbsp;<strong>Qt 5.12.2 to 5.12.5)<\/strong><\/td><td>-device linux-rpi3-g++<\/td><td>ARM V8<\/td><td>QtScript build fails<br><em>-skip qtscript <\/em>needed<\/td><\/tr><tr><td>&nbsp;&nbsp;Raspberry Pi 2<\/td><td>-device linux-rpi2-g++<\/td><td>ARM V7<\/td><td><\/td><\/tr><tr><td>&nbsp;&nbsp;Raspberry Pi 1<br>&nbsp;&nbsp;Raspberry Pi Zero<\/td><td>-device linux-rpi-g++<\/td><td>ARM V6<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The following command configure the open-source Qt version for cross compilation. Again, the particular device is set by the<strong> -device<\/strong> argument in this case <strong>linux-rasp-pi-g++<\/strong>, set the appropriate value for your board version. You can omit the compilation of problematic or time consuming modules using the <strong>-skip<\/strong> argument. In this case, we have omitted the compilation of the <strong>qtwayland<\/strong>, <strong>qtlocation<\/strong> and <strong>qtscript<\/strong> modules.<\/p>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-7505880210632883\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7505880210632883\" data-ad-slot=\"6291301981\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<div style=\"height:32px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Remember:<\/strong> For Qt <strong>5.12.2 <\/strong>to<strong> 5.12.5<\/strong>, the build configuration file must be set to <strong>linux-rasp-pi-g++<\/strong> instead of <strong>linux-rasp-pi3-g++<\/strong> in the <strong>-device<\/strong> argument.<\/p>\n\n\n\n<p>Here is my exact configuration script for Qt 5.12.5 to compile it from source with MySQL(MariaDB) Driver.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>.\/configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~\/raspi\/tools\/arm-bcm2708\/gcc-linaro-arm-linux-gnueabihf-raspbian-x64\/bin\/arm-linux-gnueabihf- -sysroot ~\/raspi\/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix \/usr\/local\/qt5pi -extprefix ~\/raspi\/qt5pi -hostprefix ~\/raspi\/qt5 -no-use-gold-linker -v -no-gbm -sql-mysql MYSQL_INCDIR=~\/raspi\/sysroot\/usr\/include\/mysql MYSQL_LIBDIR=~\/raspi\/sysroot\/usr\/lib\/arm-linux-gnueabihf<\/code><\/pre>\n\n\n\n<p>For a <strong>successful configuration<\/strong>, verify that the <strong>build options<\/strong> includes <strong>EGFLS<\/strong> for <strong>Raspberry Pi, <\/strong>it should look something like this<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>Build options:\n......\nQPA backends:\n  ......\n  EGLFS .................................. yes\n  EGLFS details:\n    ......\n    EGLFS Raspberry Pi ................... yes\n    ......<\/code><\/pre>\n\n\n\n<p>Also make sure that the database for MariaDB (MySQL) is detected.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>Qt Sql Drivers:\n DB2 (IBM) .............................. no\n InterBase .............................. no\n <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">MySql .................................. yes<\/mark><\/strong>\n OCI (Oracle) ........................... no\n ODBC ................................... no\n PostgreSQL ............................. yes\n SQLite2 ................................ no\n SQLite ................................. yes<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-compile-install-and-deploy-qt-on-the-development-pc\">Compile, install and deploy Qt on the development PC<\/h4>\n\n\n\n<p>The exact compilation time depends on your computer performance. This process can take up to 2 or 3 or more hours in nowadays common computers. Compiler processes can be executed in parallel by means of the <strong>j flag<\/strong>. For four make processes, execute: <strong><em>make -j 4<\/em><\/strong> assuming you have a CPU with 4+ cores<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>make\nmake install<\/code><\/pre>\n\n\n\n<p>Once Qt is compiled, it can be deployed to your Raspberry Pi using the <strong>rsync<\/strong> command. This step in important to get the cross compile environment working.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>rsync -avz qt5pi pi@raspberrypi_ip:\/usr\/local<\/code><\/pre>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Note<\/mark>:<\/strong> You may face some errors during the compilation the <strong>Qt 5.12<\/strong> process due to some bugs. They have been already patched in Qt 5.12.1, but this tutorial currently doesn\u2019t work for that version. You may prefer to compile the newest <strong>Qt 5.12.2<\/strong> to <strong>Qt 5.12.5<\/strong> versions to avoid these bugs.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-setup-qt-creator-for-raspberry-pi-cross-compilation-on-the-pc\">Setup Qt Creator for Raspberry Pi cross compilation on the PC<\/h4>\n\n\n\n<p>First, open Qt Creator, go to the <strong>Tools -&gt; Options<\/strong> menu, select the <strong>Devices section <\/strong>and<strong> Devices tab<\/strong>. <strong>Add<\/strong> a new <strong>Generic Linux Device<\/strong> as indicated below.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration.webp\" alt=\"Qt Device Dialog box\" class=\"wp-image-17\" width=\"461\" height=\"363\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration.webp 461w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration-300x236.webp 300w\" sizes=\"(max-width: 461px) 100vw, 461px\" \/><\/figure>\n\n\n\n<p>Set a <strong>name<\/strong> for the configuration (<em>Raspberry Pi<\/em>), the <strong>network name or IP<\/strong>, the <strong>username<\/strong> (<em>p<\/em>i) and <strong>password<\/strong> (by default <em>raspberry<\/em>).<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-default\"><img decoding=\"async\" width=\"723\" height=\"495\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration2.webp\" alt=\"Qt Dialog Linux Devices\" class=\"wp-image-18\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration2.webp 723w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration2-300x205.webp 300w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/figure>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-7505880210632883\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7505880210632883\" data-ad-slot=\"6291301981\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<div style=\"height:32px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Before you finish the wizard, the connection to your Raspberry Pi will be verified and you will have then a new device configured in Qt Creator.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"791\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration3-1.webp\" alt=\"Devices Qt\" class=\"wp-image-19\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration3-1.webp 1020w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration3-1-300x233.webp 300w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration3-1-768x596.webp 768w\" sizes=\"(max-width: 1020px) 100vw, 1020px\" \/><\/figure>\n\n\n\n<p>Next, go to the <strong>Kits section<\/strong> and <strong>Compilers tab<\/strong>, <strong>Add GCC C<\/strong> and <strong>C++<\/strong> cross compilers for Raspberry Pi.<\/p>\n\n\n\n<p>The path for the GCC<strong> C<\/strong> Raspberry Pi compiler is <strong>~\/raspi\/tools\/arm-bcm2708\/gcc-linaro-arm-linux-gnueabihf-raspbian-x64\/arm-linux-gnueabihf\/bin\/gcc<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1023\" height=\"686\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration4.webp\" alt=\"Qt Options Compilers\" class=\"wp-image-20\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration4.webp 1023w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration4-300x201.webp 300w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration4-768x515.webp 768w\" sizes=\"(max-width: 1023px) 100vw, 1023px\" \/><\/figure>\n\n\n\n<p>The path for the GCC<strong> C++<\/strong> Raspberry Pi compiler is the same as for the GCC C compiler.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1023\" height=\"686\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration5.webp\" alt=\"Qt Gcc setup for linux\" class=\"wp-image-21\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration5.webp 1023w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration5-300x201.webp 300w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration5-768x515.webp 768w\" sizes=\"(max-width: 1023px) 100vw, 1023px\" \/><\/figure>\n\n\n\n<p>Next, go to the <strong>Debuggers tab<\/strong>, and <strong>Add<\/strong> a debugger, set its path to <strong>~\/raspi\/tools\/arm-bcm2708\/arm-rpi-4.9.3-linux-gnueabihf\/bin\/arm-linux-gnueabihf-gdb<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"996\" height=\"748\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration6.webp\" alt=\"Qt Debugger setup\" class=\"wp-image-22\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration6.webp 996w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration6-300x225.webp 300w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration6-768x577.webp 768w\" sizes=\"(max-width: 996px) 100vw, 996px\" \/><\/figure>\n\n\n\n<p>Go to the <strong>Qt Versions tab<\/strong> and <strong>Add <\/strong>a<strong> new version<\/strong>: <em>Qt 5.12 (Raspberry Pi)<\/em>, set the <strong>qmake<\/strong> path to <strong>~\/raspi\/qt5\/bin\/qmake<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"996\" height=\"748\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration7.webp\" alt=\"Qt Version for cross compile setup\" class=\"wp-image-23\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration7.webp 996w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration7-300x225.webp 300w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration7-768x577.webp 768w\" sizes=\"(max-width: 996px) 100vw, 996px\" \/><\/figure>\n\n\n\n<p>Finally, go to the <strong>Kits tab<\/strong>, <strong>Add<\/strong> a <strong>new kit<\/strong>, set the <strong>name<\/strong> and <strong>icon<\/strong> you prefer, and pay attention to the following configuration:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Device type<\/strong>: Generic Linux Device<\/li>\n\n\n\n<li><strong>Device<\/strong>: Raspberry Pi (defaut for Generic Linux)<\/li>\n\n\n\n<li><strong>Sysroot<\/strong>: ~\/raspi\/sysroot<\/li>\n\n\n\n<li><strong>Compiler C<\/strong>: GCC (Raspberry Pi)<\/li>\n\n\n\n<li><strong>Compiler C++<\/strong>: GCC (Raspberry Pi)<\/li>\n\n\n\n<li><strong>Debugger<\/strong>: GDB (Raspberry Pi)<\/li>\n\n\n\n<li><strong>Qt version<\/strong>: Qt 5.12 (Raspberry Pi)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"816\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration8.webp\" alt=\"Qt Cross Compile Kits setup\" class=\"wp-image-24\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration8.webp 1024w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration8-300x239.webp 300w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration8-768x612.webp 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>All the configuration is already done. You can test your configuration by creating a<strong>new project<\/strong> and selecting the <strong>previously defined kit configuration:&nbsp;<\/strong><em>Raspberry Pi<\/em>.<\/p>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-7505880210632883\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7505880210632883\" data-ad-slot=\"6291301981\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"629\" height=\"554\" src=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration9.webp\" alt=\"Qt Kit selection\" class=\"wp-image-25\" srcset=\"https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration9.webp 629w, https:\/\/www.microfusion.org\/blog\/wp-content\/uploads\/2022\/12\/deviceConfiguration9-300x264.webp 300w\" sizes=\"(max-width: 629px) 100vw, 629px\" \/><\/figure>\n\n\n\n<p>That should do it. You can now <strong>design<\/strong>, <strong>build<\/strong> and <strong>deploy<\/strong> your Qt Raspberry Pi apps in you <strong>computer<\/strong> and, <strong>execute<\/strong> and <strong>debug<\/strong> them directly in your<strong> Raspberry Pi<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-setting-up-ssh-keys-for-qt-in-qt-5-14-1\">Setting up SSH Keys for Qt in Qt 5.14.1+<\/h4>\n\n\n\n<p>In Qt 5.14.1 when setting up devices (Raspberry Pi) in Qt creator you have to use a SSH key now. The password option is not there anymore. Have Qt generate the SSH key and copy that to your raspberry pi via SCP or what ever. The &#8220;qtc_id.pub&#8221; file goes into \/home\/pi\/.ssh then create a file called &#8220;authorized_keys&#8221; in the .ssh folder.<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>touch ~\/.ssh\/authorized_keys<\/code><\/pre>\n\n\n\n<p>next<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>cat \"qtc_id.pub\" &gt;&gt; authorized_keys<\/code><\/pre>\n\n\n\n<p>This is just to copy the name qtc_id.pub into that file as plain text. save the file and exit. Then<\/p>\n\n\n\n<pre class=\"wp-block-code has-ast-global-color-8-background-color has-background\"><code>chmod 700 ~\/.ssh\nchmod 600 ~\/.ssh\/authorized_keys<\/code><\/pre>\n\n\n\n<p>You should now be able to connect to the Raspberry Pi when setting it up in Qt creator as described in the tutorial above.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"aioseo-conclusion\">Conclusion<\/h3>\n\n\n\n<p>Qt can be somewhat intimidating when working with tool chains and devices. You should now have a working setup that will enable you to cross-compile Qt applications and debug them directly on the Raspberry Pi using your PC as the development environment . <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"aioseo-share-your-toughs-was-compiling-and-deploying-the-qt-tool-chain-easy-for-you\">Share your toughs, was compiling and deploying the Qt tool-chain easy for you ? <\/h3>\n","protected":false},"excerpt":{"rendered":"<p>A guide on how to setup and deploy Qt on a Raspberry Pi for cross compiling C++ projects<\/p>\n","protected":false},"author":1,"featured_media":67,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[24,6],"tags":[7,10,8,9],"class_list":["post-1","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-qt-programming","tag-c","tag-linux","tag-qt","tag-raspberry-pi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":16,"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":307,"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/posts\/1\/revisions\/307"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/media\/67"}],"wp:attachment":[{"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.microfusion.org\/blog\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}