Hello Kodo

This example shows how to use our build system to create a simple C++ application which depends on kodo-rlnc. The example consists of 3 files: main.cpp, wscript and waf.

main.cpp contains a very limited amount of code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// Copyright Steinwurf ApS 2015.
// Distributed under the "STEINWURF EVALUATION LICENSE 1.0".
// See accompanying file LICENSE.rst or
// http://www.steinwurf.com/licensing

//! [0]
#include <kodo_rlnc/coders.hpp>
//! [1]
#include <iostream>

int main()
{
    std::cout << "Hello Kodo!" << std::endl;
    return 0;
}

It’s basically a main function which prints Hello Kodo! and exits. In this example, we include a particular RLNC codec defined in the following header file:

1
#include <kodo_rlnc/coders.hpp>

The include is not used however. Its only purpose is to detect whether or not the include paths for the kodo-rlnc library are configured correctly.

The remaining two files are needed to build the executable. The waf file is a complete standalone build system, whereas the wscript is the recipe used by waf to build our example. The wscript contains information regarding dependencies and build targets. The simplest way to get started is to copy the hello_kodo files to a folder where you want to develop your application, and then run the standard waf commands in that folder (the cp command is Unix-only):

cd kodo-rlnc
cp -R examples/hello_kodo/ ~/my_app
cd my_app
python waf configure
python waf build

The build system will download all dependencies, compile some static libraries and finally the example. You can find the compiled executable in the waf build folder, which depends on your operating system:

  1. Linux: ./build/linux
  2. Mac OSX: ./build/darwin
  3. Windows: ./build/win32

You can directly run the executable by executing the appropriate command:

build/linux/hello_kodo
build/darwin/hello_kodo
build\win32\hello_kodo.exe

You can use this as a starting point for the coming examples, or even your own application.

For more information regarding how to use the waf build system, go here.

Note that the currently used version of kodo-rlnc is set in the resolve function of the wscript file like this:

ctx.add_dependency(
    name='kodo-rlnc',
    resolver='git',
    method='semver',
    major=12,
    sources=['github.com/steinwurf/kodo-rlnc.git'])

When a new major version is released and you want to update, you can just modify this version number and run python waf configure again to get the chosen version.