6. Build Examples

Source code for the example application included in the CC Linux reference image (CCSettingsConsole), is provided in the BSP. This can be used as a template or starting points for your applications.

Example code on how to call the functions provided by CCAux API are found in the CCAux API documentation and in the examples directory of the CCAux API source code. Additionally, this chapter provides examples on the build process.

6.1 Building applications with the SDK

This chapter gives two examples on how to build a small example application which uses CCAux API functions to set the color of the status LED. The first example shows how to build a C++ application using a Makefile. The second example shows how to build a Qt application with qmake to auto generate the Makefile.

6.1.1 C++ Makefile example

This example shows how to build a C++ application example using a Makefile. The source file example.cpp is listed below. The file consists of a simple main function calling the status LED functions.

/**
* example.cpp
**/

#include <stdio.h>
#include <FrontLED.h>
#include <CCAuxErrors.h>

using namespace CrossControl;

int main(void)
{
    printf("Setting FrontLED to blue!\r\n");

    FRONTLEDHANDLE pLed = GetFrontLED();

    eErr err;
    err = FrontLED_setStandardColor(pLed, BLUE);

    if(err != ERR_SUCCESS)
        printf("An error occurred!\r\n");

    FrontLED_release(pLed);
    return 0;
}

Following is an example Makefile that is used to build example. The additional -Wall flag enables all warnings and is recommended. This file can easily be expanded to build more complex applications.

#
# Makefile for example using FrontLed
#
# NOTE: before running make, the SDK environment must be set up by
# sourcing the environment file
#

TARGET=example
LD = $(CXX)

CC_OBJS = $(TARGET).o
C_OBJS =

OBJS = $(CC_OBJS) $(C_OBJS)

CXXFLAGS+= -DLINUX -Wall
CFLAGS+= -DLINUX -Wall
LDFLAGS+= -lcc-aux2 -lpthread

CCCMD = $(CC) -c $(CFLAGS)
CXXCMD = $(CXX) -c $(CXXFLAGS)

all:        clean $(TARGET)

$(TARGET):  $(OBJS)
    $(LD) -o $@ $(OBJS) $(LDFLAGS)

# pattern rules for object files
%.o: %.c
    $(CCCMD) $< -o $@

%.o: %.cpp
    $(CXXCMD) $< -o $@

clean:
    rm -rf *.o *.elf *.gdb *~ $(TARGET)

To build example, make sure the environment setup script has been sourced, and then issue the following command:

$ make example

make will expand the content of the Makefile and the previously sourced environment setup script to the following output (in this instance for CCpilot V700):

aarch64-poky-linux-g++  -mcpu=cortex-a35 -march=armv8-a+crc+crypto -fstack-
protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -
Werror=format-security
--sysroot=/build/jenkins/workspace/ccapi_master/cclinux_sdk/yukon/sysroots/cortexa35-
poky-linux -c -fPIC -pipe -g -feliminate-unused-debug-types -I.
-Icclinux-drivers/platform/common -I. -I../ccauxd -I -I. -Isrc -Imcp2210 -O2 -DNDEBUG=1 -
D_GNU_SOURCE=1 -pedantic -Wall -Wpointer-arith -Wsign-compare -Wcast-qual -Wfloat-
equal -DPLATFORM_V700 -DX64 -fpermissive example.o

6.2 Qt application development

CrossControl provides a pre-configured virtual machine with open-source Qt IDE and development Qt runtime for all CC Linux-based display computers.

For additional information and downloads, see https://crosscontrol.com/software-solutions/

6.3 Building any (platform supported) version of Qt with the SDK

In addition to the CrossControl provided version of Qt. You may build and integrate a preferred version for the platform, as long as Qt provides support for this.

  1. Download (or build) the SDK for your platform, and install it in to a preferred location. For this manual, the target platform is V1200/V1000. This guide will assume that the location of the SDK is:

/opt/cclinux-v1x00-2.0.5.0
Note: The path has rearranged after version 2.1, as follows;
/opt/cclinux/x.x/environment-setup-cortexa35-poky-linux
  1. Download the preferred version of Qt (https://download.qt.io/) and extract the source package to a preferred location. In this example, we will use:

  2. https://download.qt.io/official_releases/qt/5.12/5.12.12/single/qt-everywhere-src-5.12.12.tar.xz

  3. Source the cross-compilation environment from the sdk:

tuomas@YoctoDev:~/dev/qt-everywhere-src-5.12.12$ .
/opt/cclinux-v1x00-2.0.5.0/environment-setup-aarch64-poky-linux
  1. In this example, Qt will be compiled as a static library.

Note, that this will enforce certain licensing requirements for linked applications!

./configure -static \
        -opensource \
        -confirm-license \
        -prefix /opt/qt-5.12.7 \
        -hostprefix /opt/cclinux-v1x00-2.0.5.0/sysroots/x86_64-cclinuxsdk-linux/usr \
        -device linux-imx8-g++ \
        -device-option CROSS_COMPILE=$CROSS_COMPILE \
        -sysroot /opt/cclinux-v1x00-2.0.5.0/sysroots/aarch64-poky-linux \
        -nomake tests -nomake examples

The significant options are as follows:

-static     # Build qt statically, so that only the linking binary needs to be copied to the
device. Remove to build normal libraries. You will need to copy them to the target
device. Note, that statically compiled application must be open source.

-prefix     # Prefix of the library/tools installation location under the TARGET root.

-device     # Qt compilation device configuration under qtbase/mkspecs/devices (see Linx repository)

-hostprefix # Target directory for HOST tools (qmake etc)

-nomake     # Use to skipt building of various parts of qt

-skip       # Use to skip build of specific target libraries.
  1. After configure has finished, run make with the appropriate number (-j) of threads for your build system, and install the libraries in to the SDK for easy integration.

make -j8
make install
  1. This will integrate the qt-version in to your current installed SDK and enable building and debugging of qt-applications.

git clone ssh://git@euupsjb:7999/qt-example.git
cd ccmultitouchdemo
. /opt/cclinux-v1x00-2.0.5.0/environment-setup-aarch64-poky-linux
qmake
make
  1. For qt-creator integration, refer to: