Skip to navigation

Hello World

View as Markdown

Every SDK needs a smoke test, and this is Holoscan’s: the smallest possible program that proves the SDK headers, the holoscan::core library, and your build configuration all work together. There are no operators, no graph, and no runtime here — just one function call. If this example builds and prints its greeting, your toolchain is ready for everything else in Holoscan by Example.

You will learn
  • What the hello_world example does and why it exists.
  • The minimal SDK availability check: holoscan::hello().
  • The smallest CMakeLists.txt that links against holoscan::core.
  • How to build and run the example, and what success looks like.

The entire program

The example lives at public/examples/hello_world/ in the SDK tree. The source is one file, hello_world.cpp:

#include <holoscan/holoscan.hpp>
int main() {
holoscan::hello();
return 0;
}

That is the whole application. Two things are being exercised:

  • Headers resolve. <holoscan/holoscan.hpp> is the SDK’s umbrella header — it pulls in the full core API surface (operators, graphs, time, parameters, payloads). If this include compiles, your include paths and compiler configuration are correct.
  • The library links and runs. holoscan::hello() is a tiny exported function in the holoscan::core library that prints a greeting to standard output. If the call links and executes, your linker setup and runtime library loading are correct too.

holoscan::hello() exists purely as this availability check — it has no role in real applications. Think of it as the SDK’s ping.

The build file

The standalone CMakeLists.txt shows the minimal recipe for building any application against an installed SDK:

cmake_minimum_required(VERSION 4.0)
project(holoscan_hello_world LANGUAGES CXX)
find_package(holoscan REQUIRED)
add_executable(hello_world hello_world.cpp)
target_link_libraries(hello_world PRIVATE holoscan::core)

Three lines carry the weight:

  • find_package(holoscan REQUIRED) locates the SDK’s CMake package configuration through CMake’s normal package search paths. Set CMAKE_PREFIX_PATH or Holoscan_ROOT if the SDK is installed in a non-standard prefix.
  • target_link_libraries(... holoscan::core) links the core runtime. This one imported target brings the include directories, compile features, and library dependencies with it — no manual -I/-L flags.

This same pattern — find_package(holoscan) plus holoscan::core — is the starting point for every application you build outside the SDK tree.

If find_package(holoscan ...) fails with a “could not find a package configuration file” error, the SDK is not installed where CMake is looking. Verify your installation prefix and pass it explicitly, for example cmake -DCMAKE_PREFIX_PATH=/path/to/holoscan/install ... A “CMake 4.0 or higher is required” error means your CMake is too old. See SDK Installation.

Build and run

From the example directory, configure, build, and run with standard CMake:

cd examples/hello_world
cmake -B build -S .
cmake --build build
./build/hello_world

What success looks like

The program prints one line and exits with status 0:

Hello Holoscan!

That single line confirms the full chain: headers found, library linked, binary runs. The SDK’s own test suite checks exactly this — the example’s CTest entry passes when the output matches Hello Holoscan!.

If you got the greeting, your environment is ready. The next example introduces the real programming model: operators, graphs, and the compose → compile → run flow.

Recap

  • hello_world is the SDK availability check: one call to holoscan::hello(), no operators, no graph.
  • <holoscan/holoscan.hpp> is the umbrella header for the entire core API.
  • The minimal build recipe is find_package(holoscan REQUIRED) plus linking holoscan::core.
  • Success is the single line Hello Holoscan! and a zero exit status.
  • Next: Hello Tour — a guided walk through the hello_* examples that introduce each core concept.