Getting Started

Welcome to Xronos! This guide will walk you through everything you need to get up and running, from installation to your first working program.

GitHub Release GitHub License

System Requirements

Before you begin, make sure your environment meets the following requirements:

  • POSIX-compliant OS (Ubuntu 22.04 and 24.04 are tested)

  • GNU-compliant C++ compiler that supports the C++20 standard

    • gcc 11 or later

    • clang 16 or later

  • CMake 3.28 or later

Hello World

Let’s write your first Xronos program.

Application Code

In a new directory, create a file called hello.cc and paste the following content into it.

#include <iostream>

#include "xronos/sdk.hh"

namespace sdk = xronos::sdk;

class Hello : public sdk::Reactor {
  using sdk::Reactor::Reactor;

  class HelloReaction : public sdk::Reaction<Hello> {
    using sdk::Reaction<Hello>::Reaction;
    Trigger<void> startup_trigger{self().startup(), context()};
    void handler() final { std::cout << "Hello, World!\n"; }
  };

  void assemble() final { add_reaction<HelloReaction>("hello"); }
};

auto main() -> int {
  sdk::Environment env{};
  Hello hello{"hello", env.context()};
  env.execute();
  return 0;
}

CMake Config

Then create CMakeLists.txt. It uses FetchContent to download the pre-built Xronos SDK binary artifacts and links the hello executable against them. For alternative integration methods, see CMake Integration and Installation.

cmake_minimum_required(VERSION 3.28)

project(hello LANGUAGES CXX)

set(XRONOS_SDK_VERSION "0.11.2" CACHE STRING "Xronos SDK version")
include(FetchContent)
FetchContent_Declare(
  "xronos-sdk"
  URL https://github.com/xronos-inc/xronos/releases/download/v${XRONOS_SDK_VERSION}/xronos-sdk-${XRONOS_SDK_VERSION}-Linux-${CMAKE_SYSTEM_PROCESSOR}.tar.gz
)
FetchContent_MakeAvailable(xronos-sdk)
set(xronos-sdk_DIR ${xronos-sdk_SOURCE_DIR}/share/cmake/xronos-sdk)

find_package(xronos-sdk)

add_executable(hello hello.cc)
target_link_libraries(hello xronos::xronos-sdk)

Build and Run

Configure the CMake project and build:

$ cmake -B build
$ cmake --build build --target hello

Then run the program:

$ ./build/hello
Hello, World!

Generate a Diagram

Every Xronos program can be rendered into a diagram that visualizes its reactors and their relationships. Here is the diagram for our hello world example.

diagram hello

See Diagram View for instructions on how to generate a diagram view.