There are two general ways of building your own native application for the target: it can be built either manually, using the cross toolchain of the SDK, or integrated into the BSP, using Yocto and bitbake as a build system. Integrating the application into the BSP build process is the more complex way and useful only if you have modified the BSP and want to deploy a complete root file system image to the target anyway. For a single application, using the BSP in its original state as provided by SECO Northern Europe, the SDK is recommended to be used. The following sections describe how to build a simple Hello World! application using the SDK.
How to install our SDK
With each release, we also provide a compatible SDK. The SDK contains the cross-toolchain and several files like headers and libraries necessary to build software for SECO Northern Europe devices. It is available as download from the SECO Northern Europe support website.
The SDK can be found with each release in the corresponding folder that fit each of our device’s architecture.
Link to the releases on the support site can be found here.
The SDK file is a self-extracting archive that is supposed to run on Linux based machines. It is named likeseconorth-wayland-glibc-x86_64-seconorth-image-cortexa9t2hf-neon-seco-
mx6-toolchain-kirkstone-6.0.sh
.
Run this file on your development PC:
$sh <SDK location>/seconorth-wayland-glibc-x86_64-seconorth-image-
cortexa9t2hf-neon-seco-mx6-toolchain-kirkstone-6.0.sh
The installer will ask you if you want to install the SDK into a subfolder in /opt. Press Y for yes.
For more in-depth information, refer to the official Yocto documentation here.
Simple command-line application
We will create a simple C++ "Hello World!" application that uses a Makefile and the supplied SDK. Create a directory in your home directory on the host system and change to it:
$ cd ~ $ mkdir myapp $ cd myapp
Create the empty files main.cpp and Makefile in this directory:
$ touch main.cpp Makefile
Edit the contents of the main.cpp file as follows:
#include <iostream> using namespace std; int main(int argc, char *argv[]) { cout << "Hello World!" << endl; return 0; }
Edit the contents of the Makefile as follows:
myapp: main.cpp $(CXX) $(CXXFLAGS) -o $@ $< $(STRIP) $@ clean: rm -f myapp *.o *~ *.bak
It is necessary to setup your build environment so that the compiler, headers and libraries can be found. This is done by "sourcing" a build environment configuration file. If the toolchain is installed in the default directory, this example compiles for the target system by typing
$ source /opt/guf/GUF-Yocto-rocko-12.5-0-IMX6GUF-sdk/environment-setup-imx6guf-guf-linux-gnueabi $ make
in the myapp directory. The first line configures the current shell and sets the necessary environment variables. This needs to be done when shell is opened. In a new shell/terminal window or after a reboot you need to execute it again.
After a successful build, the myapp executable is created in the myapp directory. You can transfer this application to the target system’s /usr/bin directory using one of the ways described in chapter [Accessing the target system] and execute it from the device shell. It might be necessary to change the access rights of the executable first, so that all users are able to execute it.
You can find further information about how to build applications for Yocto-based platforms here.
Qt-based GUI user application
Create a new directory in your home directory on the host system and change to it:
$ cd ~ $ mkdir myqtapp $ cd myqtapp
Create the empty files main.cpp and myqtapp.pro .
$ touch main.cpp myqtapp.pro
Edit the contents of the file main.cpp as follows:
#include <QApplication> #include <QPushButton> int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setOverrideCursor(Qt::BlankCursor); QPushButton hello("Hello World!"); hello.setWindowFlags(Qt::FramelessWindowHint); hello.resize(800, 480); hello.show(); return app.exec(); }
Edit the contents of the file myqtapp.pro as follows:
TEMPLATE = app TARGET = myqtapp QT = core gui widgets SOURCES += \ main.cpp
After setting up the build environment, execute the following command to create a Makefile and build the binary in the myqtapp directory:
$ qmake myqtapp.pro $ make
Now, there is the myqtapp executable in the myqtapp directory. You can transfer this application to the target system’s /usr/bin directory and run it from the device shell.