Using Yocto/ELBE SDK for application development

From Wiki-DB
Revision as of 08:49, 22 June 2020 by Pzimmermann (talk | contribs) (Added CMake and Qt Creator)
Jump to navigationJump to search

This site is under construction!

Root filesystems made by Yocto and ELBE can come with a SDK to build applications for the rootFS.

Installation

To install the SDK the following packets have to be installed on the machine:

  • xz-utils
  • file
  • patchelf

Run the setup-script (e.g. setup-elbe-sdk-arm-linux-gnueabihf-dhcom-buster-1.0.sh) as root to start the installation.

Using the SDK

The SDK consists of two parts:

  • A folder with two sysroots
    • "host": In this folder are the programms for the development host for using the SDK (e.g. compiler, debugger, ...).
    • "target": This sysroot contains headers and libraries needed by the linker to build applications for the rootFS.
  • A file with environment variables to setup the build environment (sourcing this file sets variables like ${CC} or ${LD})

Folowing are instructions how to use the SDK with different build-systems and IDEs (All examples using an ELBE toolchain installed at "opt/elbe-sdk-arm-linux-gnueabihf-dhcom-buster-1.0"):

Makefiles

Open a shell and source the file with the environment variables:

user@machine:/<projectdir># source /opt/elbe-sdk-arm-linux-gnueabi-dhcom-buster-1.0/environment-setup-elbe-arm-linux-gnueabihf-dhcom-buster-1.0

Now you can use make to build applications in this shell session.

user@machine:/<projectdir># make

If you want to use another toolchain, you have to start a new shell session.

Important: Do not overwrite variables which were set by SDK in the makefile (or call make with '-e' to discard variables set in the makefile).

CMake

Setting up CMake to use the toolchain in the SDK is not much different than makefiles:

At first source the file with the environment variables inside a shell:

user@machine:/<projectdir># source /opt/elbe-sdk-arm-linux-gnueabi-dhcom-buster-1.0/environment-setup-elbe-arm-linux-gnueabihf-dhcom-buster-1.0

Now, for the remainder of this shell session, you can use CMake with this SDK:

user@machine:/<projectdir># cd build
user@machine:/<projectdir>/build# cmake ..
user@machine:/<projectdir>/build# cd ..
user@machine:/<projectdir># cmake --build build

If you want to use another toolchain, you have to start a new shell session.

Qt-Creator

Start Qt Creator.

Now open the "Options"-window (Tools -> Options).

In the section "Build & Run" add in the "Compilers"-tab new compilers for C and C++ (Add -> GCC --> C / C++). Set the compiler path to the fitting executable in "/opt/elbe-sdk-arm-linux-gnueabihf-dhcom-buster-1.0/sysroots/host/usr/bin/".

Example configuration for the compiler of the SDK
Example configuration for the compiler of the SDK

If the toolchain in the SDK includes Qt, switch to the "Qt Versions"-tab and add the qmake executable of the toolchain (usually in "/opt/elbe-sdk-arm-linux-gnueabihf-dhcom-buster-1.0/sysroots/host/usr/bin/qt5/qmake").

For the debugger, change to the "Debuggers"-tab and add the gdb-multiarch executable of the toolchain (usually in "/opt/elbe-sdk-arm-linux-gnueabihf-dhcom-buster-1.0/sysroots/host/usr/bin/gdb-multiarch").

If you want to deploy built software directly onto the embedded device, then change to the section "Devices" and add a new device. Select "Generic Linux Device" and set the IP-address, username and password.

Now change back to the section "Build & Run". In the tab "Kits" you have to add a new Kit for the toolchain. Set the compilers, debuggers, Qt and the device to these, which you have defined at the preceding steps. If the SDK does not include Qt you have to set Qt to "None" (like in the example).

Now you have to define the environment. Set the environment for the kit according to the environment setup file (but remove the "export" statements). If there are files inside the folders "/opt/elbe-sdk-arm-linux-gnueabihf-dhcom-buster-1.0/sysroots/host/environment-setup.d/" or "/opt/elbe-sdk-arm-linux-gnueabihf-dhcom-buster-1.0/sysroots/target/environment-setup.d/", any environment variables which are set in those have also be included.


Now any project in Qt Creator can use the toolchain of the SDK if the kit is selected for the project. If you want to use another SDK-toolchain, you can switch the used kit for the project.

Eclipse

External Links