In many cases, it is easier to include kodo-c as a shared library in
your application. With the following command, you can copy the compiled
shared library to the target folder specified by the install_path option.
In this example, we will create the shared_test folder for this purpose:

pythonwafinstall--install_shared_libs--install_path="./shared_test"

The kodo-c shared library is called libkodoc.so on Linux, kodoc.dll on
Windows and libkodoc.dylib on Mac OSX. You can link with this shared
library using your own build system. You also need to include kodoc.h
in your code. This header file is installed to the include folder within
the specified install_path.

Now we copy an existing kodo-c example (encode_decode_simple) to the
shared_test folder and we compile it to a binary called myapp:

In practice, you should set the -I and -L flags to the path where you
installed the shared library.

Now you should be able to run the new binary:

./myapp

If you dynamically link your application with the shared library, then you
have to copy the shared library to a folder where your system can find it
when you execute your application. On Windows, you typically place the DLL
in the same folder as your executable. On Unix systems, you can set the
rpath of your executable or you can adjust LD_LIBRARY_PATH to include
the path where you installed the shared library.

After building kodo-c, you can install the static libraries to your target
folder with the following command (the install_path option specifies
the target folder which will be static_test in this example):

pythonwafinstall--install_static_libs--install_path="./static_test"

The kodo-c static library is called libkodoc_static.a on Linux and Mac and
kodoc_static.lib on Windows. The install command also installs the static
libraries from the kodo-c dependencies (you will need the fifi and cpuid
libraries as well).

You can link with these static libraries using your own build system. Of course,
you will need to include kodoc.h in your code (which is installed to the
include folder within the specified install_path).

Now we copy an existing kodo-c example (encode_decode_simple) to the
static_test folder and we compile it to a binary called myapp:

In practice, you should set the -I and -L flags to the path where you
installed the static libraries.

Now you should be able to run the new binary (note that this binary will
be quite large, since it includes all the static libraries):

./myapp

It is important to note that you need to link with the C++ standard library
(by using -lstdc++ above), because the kodo-c library actually wraps a
C++ library (kodo) that uses the C++ standard library. However, you can omit
this flag if you link your application with g++ instead of gcc (g++
automatically includes the stdc++ library):

Where {android-sdk} and {android-ndk} should be replaced with your
path to the Android SDK and a standalone version of the Android NDK.

After building kodo-c with the specified mkspec, you can install the generated
static libraries to examples/android_app/app/src/main/jni/libs/armeabi-v7a.
It is also recommended to copy the kodoc.h header to
examples/android_app/app/src/main/jni/kodoc/kodoc.h.
After this, you need to adjust the build settings in
examples/android_app/app/src/main/jni/Android.mk. The preconfigured
solution shows how to link with the static libraries: kodocfificpuid.

Note

If you want to use the generated static libraries with ndk-build,
then make sure that you process at least one C++ source file (.cpp)
with ndk-build (this might be a dummy cpp file). Otherwise you
will get a lot of linkage issues, because ndk-build does not link
with the C++ standard library by default.

Right click in the Project panel, then select: New -> Folder -> JNI Folder.

This will create a folder called C in the project panel
(note: the actual name of this folder on the filesystem is jni).

Go to this newly generated directory and use javah to generate the
JNI headers, using the following command:

javah-cp{android-sdk}/platforms/android-16/android.jar:../java{class}

Replace {android-sdk} with the path to the Android SDK on your
machine, and {class} with the name of the class. In the dummy_android
sample project, this would be com.steinwurf.dummy_android.MainActivity.
You can generate JNI headers for any class in your project.

The examples/ios_app/kodoc-ios-demo folder contains an iOS demo
project that can be opened in XCode. This project uses the iOS multi-arch
libraries that can be compiled by running the following helper scripts:

cdexamples/ios_appshconfigure_and_build_all.shshbuild_ios_fat_libs.sh

This project should work on all architectures (device and simulator)
after you execute the helper scripts.

If you want to include kodo-c in your own Xcode project, then please set
the library and include path options as follows:

Specify the library path and dependencies in “Link Binary with Libraries”
under “Build Phases” in the project navigator.

Specify the include path in “Header Search Paths” under “Search Paths”,
in the “Build Settings”.

The helper scripts provided above can automate the build process, but you
can also configure and compile kodo-c manually for your desired architecture by
executing the following commands from the root of the kodo-c repository: