ANSI C UA Server SDK  1.6.0.341
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
Cross Compiling the SDK

The following sections demonstrate how to cross compile the SDK for Linux on an ARM platform as example.

Although these instructions can be in principle applied to other target systems, there may be some differences. Please refer to CMake Cross Compiling (link to CMake Wiki) for more information.

Requirements

You’ll need the following software:

  • CMake (2.8.0 or higher)
  • a cross compiler toolchain for your target platform; in our example, we have unpacked it to /usr/local/angstrom/arm
  • the required third-party libraries compiled for your target platform; see Compiling Third-Party Components for instructions

Toolchain File

CMake needs to know the target system and where the tools from the cross compiling toolchain can be found. The information can be put together in a so-called toolchain file (link to CMake Wiki). In our case, it has the following content:

# this one is important
set(CMAKE_SYSTEM_NAME Linux)
# specify the cross compiler
set(CMAKE_C_COMPILER /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-g++)
# Name of archiving tool for static libraries
set(CMAKE_AR "/usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-ar" CACHE PATH "ARM Linux ar Program")
# where is the target environment (compiler and third-party)
set(CMAKE_FIND_ROOT_PATH <third-party library install path> /usr/local/angstrom/arm /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi)
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Create Makefiles for the SDK

Once we have a toolchain file, cross compiling the SDK is not very different as described at Recompiling the SDK and Examples (Linux). We have to specify the toolchain file when starting ccmake:

ccmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-linux-arm.cmake ../src

Press “c” to configure, then change the settings to your liking, e.g. set CMAKE_INSTALL_PREFIX to “Release” and specify a different CMAKE_INSTALL_PREFIX (see screenshot).

xcompilesdk_ccmake.png

Now press “c” to configure again, followed by “g” to generate makefiles. When finished, we are able to compile the SDK and install it to the directory specified by CMAKE_INSTALL_PREFIX:

make
make install

Create Makefiles for the Examples

Creating makefiles for the SDK works in a similar way. Create a new folder inside the SDK installation directory, e.g. “bldexamples”, change to the folder and start ccmake, specifying the directory “examples” as source directory.

mkdir bldexamples
cd bldexamples
ccmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-linux-arm.cmake ../examples

Press “c” to configure, set CMAKE_INSTALL_PREFIX to “Release”, specify the same CMAKE_INSTALL_PREFIX as above.

When finished, press “c” to configure again, followed by “g” to generate makefiles. Now you can compile and install the examples:

make
make install