C++ Guide
This guide shows how to set up a C++ project to use the GRX API with CMake, compile the Protocol Buffer definitions, and build a simple client application.
Prerequisites
C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
CMake 3.16 or later
gRPC and Protocol Buffers libraries
Installing gRPC on Linux (Ubuntu/Debian):
# Install build tools
sudo apt install -y build-essential cmake pkg-config
# Install gRPC and protobuf via system packages (if available)
sudo apt install -y libgrpc++-dev protobuf-compiler-grpc
# Or build from source (recommended for latest versions):
# See https://grpc.io/docs/languages/cpp/quickstart/
Installing gRPC on Windows:
Use vcpkg to install gRPC:
vcpkg install grpc
Step 1: Project Structure
Create the following directory layout:
my_grx_project/
├── CMakeLists.txt
├── proto/
│ ├── Common.proto
│ ├── Receiverd.proto
│ ├── Monitord.proto
│ ├── Spectrumd.proto
│ ├── Samplestreamingd.proto
│ └── TunableChanneld.proto
├── tracked_aircraft.cpp
└── modes_downlink.cpp
Download the .proto files from the Protocol Buffer Definitions section and
place them in the proto/ directory.
Step 2: CMakeLists.txt
Download the CMake build file:
This CMakeLists.txt automatically generates C++ bindings from the .proto
files at build time and links against gRPC and Protobuf.
Step 3: Examples
Download the example source files:
tracked_aircraft.cpp– Retrieves and prints all tracked aircraft (unary RPC).modes_downlink.cpp– Subscribes to Mode S downlink frames DF11/DF17 (server-side streaming RPC).
Step 4: Build and Run
mkdir build && cd build
cmake ..
make
./tracked_aircraft YOUR_GRX_IP
./modes_downlink YOUR_GRX_IP
Cross-Platform Notes
Linux: gRPC can be installed via system packages or built from source. The
CMake find_package approach works with both.
Windows: Use vcpkg with the CMake toolchain file:
cmake -B build -DCMAKE_TOOLCHAIN_FILE=[vcpkg-root]/scripts/buildsystems/vcpkg.cmake
cmake --build build
macOS: Install gRPC via Homebrew:
brew install grpc protobuf