This is documentation for the old, first-generation Kaa platform v0.x.
Next generation Kaa Enterprise IoT platform is now available! Try it free with a 30-days trial.
Kaa Enterprise documentation is here.
. . .


This section describes how to build Kaa C SDK on a Linux-based machine and install a Kaa application.

The application code based on Kaa C SDK is similar for most of the supported platforms. However, the build system is not.

This guide is focused on the details of the CMake-based build system that is used to tie application code together with the C SDK.

NOTE: This guide is verified against Ubuntu 14.04 LTS Desktop 64-bit.


To build Kaa C SDK, make sure to install the following components:

  • CMake (minimum required version is 2.8.12).
  • C99 compatible compiler (e.g. GCC).

To install dependencies on Ubuntu, execute the following command:

sudo apt-get install cmake build-essential

Build C SDK

To build Kaa C SDK:

  1. Generate your C SDK.

  2. Unpack the C SDK archive.

    tar -xvf c-sdk-archive-name.tar.gz
  3. Create a directory where the SDK will be built.

    mkdir build
    cd build
  4. Configure the build via CMake.

    cmake ..
  5. Perform build.


Build Kaa application

After you installed the required dependencies and built the C SDK, you can build and run your Kaa application. To do this:

  1. Create directories for your build structure. For example, you can create the following directories:

    • my-kaa-application – root directory containing all files;
    • my-kaa-application/kaa – contains the C SDK source files;
    • my-kaa-application/src – contains the application code.
    mkdir my-kaa-application
    mkdir my-kaa-application/kaa
    mkdir my-kaa-application/src
    cd my-kaa-application
  2. Generate C SDK and unpack it to the my-kaa-application/kaa directory.

    tar -xvf c-sdk-archive.tar.gz -C my-kaa-application/kaa
  3. In my-kaa-application/src directory, create a kaa-application.c file that will contain the application code.

    touch src/kaa-application.c

    Open the kaa-application.c file and write the application code in it. For the sake of example, a very simple application will be built that displays a string: Hello, I am a Kaa Application!\n.

     #include <stdio.h>
     #include <stdlib.h>
     #include <kaa/kaa.h>
     #include <kaa/platform/kaa_client.h>
     #include <kaa/kaa_error.h>
     static void dummy_function(void *context)
         printf("Hello, I am a Kaa Application!\n");
     int main(void)
         kaa_client_t *kaa_client = NULL;
         kaa_error_t error = kaa_client_create(&kaa_client, NULL);
         if (error) {
             return EXIT_FAILURE;
         error = kaa_client_start(kaa_client, dummy_function, (void *)kaa_client, 0);
         if (error) {
             return EXIT_FAILURE;
         return EXIT_SUCCESS;
  4. Create a CMakeLists.txt file in the my-kaa-application directory. It is a top-level CMake file handling the application build.

    touch CMakeLists.txt

    Add the following code to the CMakeLists.txt file. The first line sets the minimum CMake version required to build a kaa-application project. The second line sets project name and language.

    cmake_minimum_required(VERSION 2.8.12)
    project(kaa-application C)

    Some compilers flags are set, and C SDK project is included as a subproject to the kaa-application project. That is a clue. The parameter contains a path to the C SDK’s CMakeLists.txt.

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -Wall -Wextra")

    Compile the executable file kaa-app using src/kaa-application.c, and link it with kaac.

    add_executable(kaa-app src/kaa-application.c)
    target_link_libraries(kaa-app kaac)

    See the full CMakeLists.txt code below.

    cmake_minimum_required(VERSION 2.8.12)
    project(kaa-application C)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -Wall -Wextra")
    add_executable(kaa-app src/kaa-application.c)
    target_link_libraries(kaa-app kaac)
  5. Now your directory structure should look like this.

    - my-kaa-application
      - CMakeLists.txt
      - kaa
        - Unpacked C SDK
      - src
        - kaa-application.c
  6. Finally, you can build the application. Create a build directory.

    mkdir build
    cd build
  7. Configure the build via CMake and run the make command.


    KAA_MAX_LOG_LEVEL parameter is used here to decrease log level which is set by default to eliminate output pollution.

    BUILD_TESTING is ON by default. Switch it to OFF to prevent running tests.

  8. Run your application.


    You should observe the following output.

    Hello, I am a Kaa Application!

See full source code on GitHub.

For more information about writing application code, see Programming guide.