Insight Agent for Linux

Building and testing

linux
apt-get update && apt-get install -y gcc g++ cmake ca-certificates valgrind libssl-dev libcrypto++-dev

Building for your local development platform

To build the library, run the following command in the terminal:

sh buildScripts/build.sh local

That will produce the following artefacts:

  • build/build/NativeInsightAgent-X.X.X-Platform-CPU.tar.gz - Static version of the library and headers

  • build/bin - Binary dummy/reference application that uses the library

Passing GCC Flags to the build

You may pass as many GCC flags to the build system through the GCC_FLAGS environment variable, as shown in the example below:

export GCC_FLAGS="-fstack-protector-all -pipe -Wl,-z,combreloc -Wa,--noexecstack -z`

Building for your target device using your platform toolchain

You will need two things:

  • Build OpenSSL using your toolchain and let the build system know where it is located.

  • Create a cmake toolchain file and let the build system know where it is located.

Build OpenSSL

Currently, the build system does not automatically download and build OpenSSL with your custom toolchain, so you will have to do it on your own.

Download OpenSSL

mkdir -p ~/cross-openssl/compiled-openssl && cd ~/cross-openssl
curl https://www.openssl.org/source/openssl-1.1.1h.tar.gz | tar -xz 
cd openssl-1.1.1h

Build OpenSSL with your toolchain

export INSTALL_DIR=~/cross-openssl/compiled-openssl
export TOOLCHAIN_BIN_DIR=/path/to/your/toolchain/bin

Set your OS name, for example, linux-armv4, and build OpenSSL

export TARGET_PLATFORM=linux-armv4
./Configure $TARGET_PLATFORM shared \
--prefix=$INSTALL_DIR --openssldir=$INSTALL_DIR/openssl \
--cross-compile-prefix=$CROSS_DIR/arm-linux-gnueabihf-
make depend
make install

Set the environment variable CMAKE_OPENSSL_ARGS so that the Insight Agent build system knows where to locate it

export CMAKE_OPENSSL_ARGS="-DOPENSSL_SSL_LIBRARY=~/cross-openssl/compiled-openssl/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARY=~/cross-openssl/compiled-openssl/lib/libcrypto.a -DOPENSSL_INCLUDE_DIR=~/cross-openssl/compiled-openssl/include"

Building the Insight Agent with your toolchain

To build the library using a custom toolchain you must create a custom toolchain-file.cmake with the information about your toolchain. You can find some examples in the toolchain folder. You must also set the environment variable TOOLCHAIN_CMAKE_FILE with the path to such toolchain. For example:

export TOOLCHAIN_CMAKE_FILE=/path/to/toolchain/file/linux-arm32.cmake

Now that you have set up the toolchain file and the references to your build of OpenSSL with your toolchain in the environment variables, you may call:

sh buildScripts/build.sh device

That will produce the following artefacts:

  • build/build/NativeInsightAgent-X.X.X-Platform-CPU.tar.gz - Static version of the library and headers.

  • build/bin - Binary dummy/reference application that uses the library.

How to Test

To build and run the unit tests, run the command below in the terminal

sh buildScripts/test.sh