7. 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.

7.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.

7.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

7.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/

7.3 Cross Compiling additional softwares using Yocto SDK

In addition to the CrossControl provided softwares or packages, you may build and integrate additional softwares for the platform using Yocto SDK provided by Crosscontrol. Also, you may build and integrate preferred version of particular software apart from CrossControl provided version of the software.

For this manual, the target platform is V1200/V1000 is considered. This guide will assume that the location of the SDK is:

/opt/cclinux-v1x00-4.x.x.x

Then the platform environment can be setup for cross compilation by sourcing the environment script from the SDK as below:

./opt/cclinux-v1x00-4.x.x.x/environment-setup-cortexa35-poky-linux

In this example, OpenCV 4.10.0 will be built and integrated into the platform using Yocto SDK provided by CrossControl

. /opt/V1X00/environment-setup-cortexa35-poky-linux

mkdir opencv

wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/4.10.0.zip

wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/refs/tags/4.10.0.zip

unzip opencv.zip

unzip opencv_contrib.zip

mkdir build-imx8 && cd build-imx8

# Cross-Compile for IMX8 (assumes SDK is installed to /opt/V1X00 folder)
cmake -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/opt/V1X00/OpenCV-4.10.0  \
    -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.10.0/modules \
    -D WITH_OPENMP=ON \
    -D WITH_OPENCL=ON \
    -D WITH_TBB=ON \
    -D BUILD_SHARED_LIBS=ON \
    -D BUILD_OPENJPEG=ON \
    ../opencv-4.10.0

cmake --build . --parallel 10

Note

!!! Make sure with licensing requirements for the softwares or packages that is going to be integrated !!!