Skip to main content

C / C++ SDK

RBS provides native C and C++ support with compilation, linking, shared library management, and hermetic launcher scripts that handle LD_LIBRARY_PATH / DYLD_LIBRARY_PATH automatically.

Rules

C Rules

c_library

Creates a C static library (object archive).
AttributeTypeDescription
namestringUnique target name (required).
srcslistC source files (.c).
hdrslistHeader files (.h).
depslistDependencies (c_library or c_shared_library).
cflagslistExtra compiler flags (e.g., -O2, -Wall).

c_shared_library

Creates a C shared library (.so / .dylib).

c_binary

Creates an executable C binary with a hermetic launcher script.
AttributeTypeDescription
namestringUnique target name (required).
srcslistC source files.
hdrslistHeader files.
depslistDependencies.
cflagslistCompiler flags.
ldflagslistLinker flags.

C++ Rules

cxx_library

Creates a C++ static library.
AttributeTypeDescription
namestringUnique target name (required).
srcslistC++ source files (.cpp, .cc).
hdrslistHeader files (.h, .hpp).
depslistDependencies.
cxxflagslistC++ compiler flags.

cxx_shared_library

Creates a C++ shared library.

cxx_binary

Creates an executable C++ binary.

Shared Library Handling

When a c_binary or cxx_binary depends on shared libraries, RBS automatically:
  1. Copies shared libraries into the target’s runfiles/lib/ directory.
  2. Generates a launcher script that sets LD_LIBRARY_PATH (Linux) and DYLD_LIBRARY_PATH (macOS) to point to the bundled libraries.
This ensures the binary always finds its shared libraries without requiring system-wide installation.

Example