We have provided several C++ examples in directory
gtirb/doc/examples
. See the Examples page for more
information.
The remainder of this section provides examples walking through common tasks using the GTIRB C++ library API.
To build and install GTIRB, the following requirements should be installed in addition to the common requirements:
- Boost, version 1.67.0 or later.
- No version of Ubuntu provides this version of Boost yet; you must build it from source.
CMake can optionally use a toolchain file, as generated by
Microsoft's vcpkg, to find packages like
boost or protobuf on Windows. One way to install GTIRB's dependencies is to run
vcpkg
before running cmake
:
vcpkg.exe install --triplet x64-windows protobuf boost
and pass the path to the toolchain file when executing the CMake command above:
-DCMAKE_TOOLCHAIN_FILE="C:\path\to\vcpkg\scripts\buildsystems\vcpkg.cmake"
Note that, to compile a C++ client that uses the GTIRB library,
you have to inform the compiler and linker where to find GTIRB's
header files and library archives. In addition, the OS also needs to
be informed about where to find GTIRB's dynamic libraries. These files
are located under include
and lib
in the build output directory
you picked when running CMake originally. How to do this will depend
on the particular compiler tool chain and context you are working
with.
If the C++ client in question also uses CMake, then it can find gtirb as a dependency by adding this to thier CMakeLists.txt
:
find_package(gtirb REQUIRED)
See example.cpp for a basic introcution to using the GTIRB API in C++.