Installation
This guide walks you through building the Cerulion RCL Hooks shared library from source. The build process creates a shared library (.so file) that will be loaded into your ROS 2 processes.
Prerequisites
Before you begin, ensure you have:Rust Toolchain
Rust and Cargo installed (the hooks are written in Rust)
ROS 2 Development
ROS 2 development libraries and headers installed
Build Tools
Standard build tools:
make, gcc, pkg-configRepository Access
Access to the Cerulion development repository
If you don’t have Rust installed, you can get it from rustup.rs. ROS 2 installation depends on your distribution - see the ROS 2 documentation for your specific setup.
Building the Shared Library
The build process compiles the Rust code into a shared library that can be loaded withLD_PRELOAD. Let’s walk through it step by step.
1
Navigate to the repository root
Change to the Cerulion development repository directory:
2
Build the debug version
Build the This command:
cerulion_rcl_hooks package using Cargo:- Compiles the Rust code
- Links against ROS 2 libraries
- Generates the shared library file
The
-p flag specifies which package to build. This is useful when working in a workspace with multiple packages.3
Locate the output file
After a successful build, you’ll find the shared library at:
Verify the file exists and has a reasonable size (typically several megabytes):
4
Build the release version (optional)
For production use, build an optimized release version:The release build:
- Optimizes the code for performance
- Reduces binary size
- Takes longer to compile
Understanding the Build Output
Shared Library File
The.so file is a shared library (similar to .dll on Windows or .dylib on macOS). This file contains:
- The hook functions that intercept ROS calls before serialization
- Message hijacking and shared memory publishing code
- Schema loading logic
- All necessary dependencies
Build Artifacts
Thetarget/ directory contains:
target/debug/- Debug build with symbols for debuggingtarget/release/- Optimized release build- Intermediate compilation artifacts (you can ignore these)
Schema Files
The hooks rely on schema files to understand ROS message types. These schemas are located in:What are Schemas?
Schemas are YAML files that describe:- ROS message structure
- Field types and names
- How to map ROS message fields to Cerulion’s format (note: Cerulion doesn’t serialize - it publishes directly to shared memory)
Schema Location
Schemas are loaded at runtime when the hooks encounter a new message type. The hooks automatically look for schemas in theschemas_ros2/ directory relative to where the library is loaded.
You don’t need to rebuild the hooks when adding new schemas - just place new YAML files in
schemas_ros2/ and they’ll be loaded automatically when needed.Verifying the Build
After building, verify everything is correct:1
Check file exists
2
Check dependencies
Verify the library can find its dependencies:This shows all libraries the hooks depend on. Make sure ROS 2 libraries are listed.
3
Check schema directory
Verify the schema directory exists:You should see YAML files for common ROS message types.
Troubleshooting Build Issues
Build fails with 'cannot find crate'
Build fails with 'cannot find crate'
This usually means dependencies aren’t installed. Try:If that doesn’t work, check that you’re in the correct workspace directory.
ROS 2 libraries not found
ROS 2 libraries not found
Ensure ROS 2 development packages are installed. On Ubuntu/Debian:Replace
<distro> with your ROS 2 distribution (humble, iron, etc.).Linker errors
Linker errors
If you see linker errors, make sure:
- ROS 2 environment is sourced:
source /opt/ros/<distro>/setup.bash - All ROS 2 development packages are installed
- Your Rust toolchain is up to date:
rustup update