HIO Wiki:Set Up Qt Creator for Yocto Device

From HIO Wiki
Jump to: navigation, search

About

Qt Creator is one of the most popular software development software. It is a cross-platform C++, Javascript and QML integrated development environment. Qt includes a visual debugger and an integrated GUI layout and form designers. This article will show steps by steps on how to Install Qt Development tool on the host computer to develop programs for the Yocto embedded device.

Build and Install SDK

Different setup of machines will have different SDK. The below set-up is for HIO-Yocto sample image build-fb.

Setup MACHINE and build directory

The directory name we will be using is "build-fb" and we will use that to build the SDK

Change path to where Yocto Environment is set up. E.g. /hio-yocto-bsp

$ cd hio-yocto-bsp
~/hio-yocto-bsp/$ export MACHINE=hio-imx6dl-board
~/hio-yocto-bsp/$ . ./setup-environment build-fb

Note: Refer to Build-fb bblayer.conf and local.conf for configuration.

Compile Toolchain

$ bitbake meta-toolchain-qt5

Note: This process might take several hours.

Install The Hio-Yocto SDK

After finish compiled with bitbake, obtain the SDK file located in /build-fb/tmp/deploy/sdk

Install the SDK,

~/hio-yocto-bsp/build-fb/tmp/deploy/sdk$ sudo sh poky-eglibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-1.6.1.sh

The default path will be /opt/poky/1.6.1

Set Up Qt Creator

Download and Install Qt Creator

Download QT Creator Linux X64 - 5.4.0

$ chmod +x qt-opensource-linux-x64-5.4.0.run
$ sudo ./qt-opensource-linux-x64-5.4.0.run

Follow installation wizard instructions.

Create Hio-Yocto Environment

First, locate the environment-setup file in /opt/poky/1.6.1

 /opt/poky/1.6.1/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi

Next, use a text editor to edit /opt/Qt5.4.0/Tools/QtCreator/bin/qtcreator.sh

Add the environment setup directories into the first line (Before #! /bin/sh)

source /opt/poky/1.6.1/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi 


Activate QT Creator

Change directory to where QtCreator is installed /opt/Qt5.4.0/Tools/QtCreator/bin

$: sudo sh qtcreator.sh

Note: if qtcreator.sh returns source: not found, before sudo sh qtcreator.sh, enter sudo dpkg-reconfigure dash and choose no.

Configure Qt creator

Connect to Target Device

Connect the target system to a network and get its IP address.

  • In QtCreator
  • Go to Tools > Options > Devices
  • Click Add > Generic Linux Device > Start Wizard
  • Set the name to "Hio Board" and set up the connection.

Click Test to test the network connection of the target device.
Devices.PNG

Add new Compiler

  • Go to Tools > Options > Build & Run> click Compilers
  • Click Add and select GCC
  • Change Name to "Hio-fb-compiler-cpp"
  • Select poky compiler:
/opt/poky/1.6.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-cpp 

Compiler.PNG

Add New Cross Compiled QtVersion

  • Click Qt Versions on the Build & Run panel
  • Click Add
  • Locate the qmake file in /opt/poky/1.6.1/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake

QtVersion.PNG

Add new Kit

  • Click on Kits on the Build & Run panel
  • Click Add
Name: Hio Board Qt 5.2.1
Device Type: Generic Linux Device
Device: Hio Board
Sysroot: /opt/poky/1.6/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi 
Compiler: Hio-fb-compiler-cpp
...
Qt Version: Qt 5.2.1(qt5)
...
  • Click Ok

Kits.PNG

Test: Qt Creator Hello World

  • Open Qt Creator and click New Project
  • Select Qt Console Application
  • Specify the location for the project
  • Next: select the kit the Hio Board Qt 5.2.1 and click Finish
  • Edit hello-world.pro, add these lines under Target to specify where the applications gets installed when it is deployed to the device during development
linux-*{
    target.path =/home/root/
    INSTALLS += target
}
  • Edit main.cpp
#include <QCoreApplication>
#include <iostream>
#include <stdlib.h>

using namespace std;
int main(int argc, char *argv[])
{
    QCoreApplication a(argc,argv);
    cout<<"Hello World"<<endl;
    return a.exec();
}
  • Click the Green Button in the bottom left to run the application.

HelloWorld.PNG