§Getting started with libtiro

The following instructions assume a reasonably up-to-date Linux or Unix system.

§Building from source

As the first step, use git to clone the repository:

$ git clone https://github.com/mbeckem/tiro.git

§Requirements

The following tools must be installed on your system to build tiro:

  • A C++17 compiler. The following compilers are tested regularly:

    • gcc 8, 9 (Linux )
    • clang 9, 10 (Linux)
    • xcode 11 (OSX)

    MSVC is currently not supported (minor adjustments are necessary to make tiro compile). clang-cl should work.

  • CMake >= 3.13

No other external tools or libraries are needed. Library dependencies needed by tiro (listed here) will be fetched automatically during the build.

§Building and installing

Create a build directory, configure cmake and then run your build system.

The following example performs a system wide installation of tiro and assumes root privileges.
You can chose a custom location by specifying -DCMAKE_INSTALL_PREFIX=/your/install/prefix.

$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -DTIRO_LTO=1 ..
$ make -j8
$ make install

The following cmake variables can be useful to customize the build process:

CMake VariableDescription
TIRO_LTO = ON | OFFOptional (off by default). Attempts to enable link time optimization, if supported by the compiler. Results in smaller and more optimized output and is recommended in release builds.
TIRO_WARNINGS = ON | OFFOptional (off by default). Enables pedantic warnings, mainly used during development.
TIRO_TESTS = ON | OFFOptional (off by default). Also build test executables when enabled (placed into build/bin).

After the build has completed, the compiled output can be found in your install prefix:

<install prefix>
|-- include
| |-- tiro # C headers for libtiro.so
| `-- tiropp # C++ headers for libtiro.so
`-- lib
|-- cmake # CMake support scripts
`-- libtiro.so # tiro as a shared library

§Create a simple test program

Create a simple program that links against libtiro and prints its current version:

Example: hello.c
#include <tiro/version.h>
#include <stdio.h>
int main() {
printf("Hello from %s\n", tiro_full_version());
}

Now compile and run your application. Make sure that libtiro.so and tiro/version.h can be found by your compiler.

$ gcc hello.c -o hello -ltiro
$ ./hello
Hello from tiro 0.1.0-dev (git:ae107e2bc05173d8dfa49de21094252271de133a)

§Next steps

More complex examples are maintained in the Github repository.

The C++ embedding example demonstrates how to use the C++ API in your application.

§Further documentation

The full build system reference is maintained in the tiro source repository: Reference.