Remote Compilation - qtec/build-qt5022-core GitHub Wiki

Remote Compilation

Instead of building your applications in the camera, you might want to build them on your development machine. This is supported on Qtechnology cameras via a Software Development Kit. You can read the full documentation at Yocto official page.

On the next lines we will show you how a simple hello world can be build using the Standard SDK.

  • You need to download the SDK image in your computer.

  • Then you will launch the SDK installer:

chmod a+x poky-qtec-glibc-x86_64-qtec-core-dev-image-bobcat_64-toolchain-2.1.1.sh 
./poky-qtec-glibc-x86_64-qtec-core-dev-image-bobcat_64-toolchain-2.1.1.sh

It will ask you for an installation folder. By default is /opt/poky-qtec/2.1.1 . If you want to install the SDK in that location make sure that the folder /opt/poky-qtec/ exists and is user writable.

  • To activate the SDK just run:
source /opt/poky-qtec/2.1.1/environment-setup-bobcat_64-poky-linux

Once this is done the following variables are set automatically for you:

CONFIG_SITE=/opt/poky-qtec/2.1.1/site-config-bobcat_64-poky-linux
SDKTARGETSYSROOT=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
KCFLAGS=--sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
OECORE_ACLOCAL_OPTS=-I /opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/share/aclocal
CC=x86_64-poky-linux-gcc  -m64 -march=btver1 -mtune=btver1 --sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
PKG_CONFIG_SYSROOT_DIR=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
CONFIGURE_FLAGS=--target=x86_64-poky-linux --host=x86_64-poky-linux --build=x86_64-linux --with-libtool-sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
OECORE_NATIVE_SYSROOT=/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux
CXX=x86_64-poky-linux-g++  -m64 -march=btver1 -mtune=btver1 --sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
CCACHE_PATH=/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/../x86_64-pokysdk-linux/bin:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux-uclibc:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux-musl:
OECORE_TARGET_SYSROOT=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
PATH=/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/sbin:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/bin:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/sbin:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/../x86_64-pokysdk-linux/bin:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux-uclibc:/opt/poky-qtec/2.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux-musl:/home/ricardo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
PKG_CONFIG_PATH=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux/usr/lib/pkgconfig
CPP=x86_64-poky-linux-gcc -E  -m64 -march=btver1 -mtune=btver1 --sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux
LD=x86_64-poky-linux-ld   --sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux

An standard Makefile will make use of this variables.

  • Lets create a hello wold example

with your favourite editor Create a file with this content and name it hello.c

#include <stdio.h>

int main(int argc, char *argv[]){

	fprintf(stdout, "Hello Camera!\n");

	return 0;
}

And create a Makefile with this content

TARGETS = hello

all: ${TARGETS}

clean:
	${RM} ${TARGETS} core *.o

now prepare the SDK environment:

source /opt/poky-qtec/2.1.1/environment-setup-bobcat_64-poky-linux 

and launch make

ricardo@neopili:/tmp$ make
x86_64-poky-linux-gcc  -m64 -march=btver1 -mtune=btver1 --sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux  -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/var/lib/jenkins/workspace/qt5022-fglrx-github/build/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-qt5022-fglrx/1.0-r8=/usr/src/debug/meta-environment-qt5022-fglrx/1.0-r8 -fdebug-prefix-map=/var/lib/jenkins/workspace/qt5022-fglrx-github/build/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/var/lib/jenkins/workspace/qt5022-fglrx-github/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux=   -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed  hello.c   -o hello

as you can see, make has used the installed SDK (also know as toolchain) to compile hello

If we try to execute the file on our computer, this will fail. The binary has been built for the camera, not for our computer.

ricardo@neopili:/tmp$ ./hello 
bash: ./hello: No such file or directory

We need to copy the file to the camera via ssh and execute it there

ricardo@neopili:/tmp$ scp hello [email protected]:
hello                                                       100%   13KB   3.6MB/s   00:00 
ricardo@neopili:/tmp$ ssh [email protected]
qt5022-fglrx:~$ ./hello 
Hello Camera!

Using libraries

All the libraries installed by default on our image are also available on the sdk, so you can make use of them automatically.

Check out this Makefile for an OpenCV app:

TARGETS = cv

CFLAGS += $(shell pkg-config --cflags opencv)
LDLIBS += $(shell pkg-config --libs opencv)

all: ${TARGETS}

clean:
	${RM} ${TARGETS} core *.o

and how it is executed:

ricardo@neopili:/tmp$ make
x86_64-poky-linux-gcc  -m64 -march=btver1 -mtune=btver1 --sysroot=/opt/poky-qtec/2.1.1/sysroots/bobcat_64-poky-linux  -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/var/lib/jenkins/workspace/qt5022-fglrx-github/build/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-qt5022-fglrx/1.0-r8=/usr/src/debug/meta-environment-qt5022-fglrx/1.0-r8 -fdebug-prefix-map=/var/lib/jenkins/workspace/qt5022-fglrx-github/build/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/var/lib/jenkins/workspace/qt5022-fglrx-github/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux=    -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed  cv.c   -o cv

Eclipse development and Extensible SDK

Yocto SDK also provides an Eclipse Plugin and and extensible SDK, in which you can add libraries that don't make part of the standard image. Check out the official documentation for more information.

⚠️ **GitHub.com Fallback** ⚠️