Use the Lattice SDK for gRPC in C++
This page shows you how to set up the Lattice SDK for gRPC in C++ and make a gRPC request.
Click to go to the gRPC SDK repository. By downloading and/or using, you agree to the terms of use. If you do not agree, do not use the SDK.
Before you begin
Before you install and use the Lattice SDK in C++, do the following:
-
Install gRPC versions 1.68.0 and Protobuf version 29.0.0.
C++ requires the versions to be an exact match between its generated code version and its runtime version at all times. For more information or to use alternative versions, see C++ requirements.
Define the CMakeLists.txt
-
Run the following command to create, and navigate to, a new project folder
mkdir lattice-sdk-example && cd lattice-sdk-example
-
Copy and paste the following to define your
CMakeLists.txt
file. TheCMakeLists.txt
file defines your project's basic properties and its dependencies, including the Lattice SDK in C++. You also define your executable here. In the following example, your executable is calledcli_client
. You'll use this executable file to run your application:warningUse the latest version of GIT_TAG to avoid issues from gRPC or Protobuf dependency updates, as it includes the specific versions used for building.
cmake_minimum_required(VERSION 3.25.0)
project(lattice-sdk-example)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Download the SDK from github and add it as part of the project
include(FetchContent)
FetchContent_Declare(
lattice-sdk-cpp
GIT_REPOSITORY https://github.com/anduril/lattice-sdk-cpp.git
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(lattice-sdk-cpp)
# Build the text-only CLI and link against the Lattice SDK.
add_executable(cli_client main.cpp)
target_link_libraries(cli_client lattice-sdk-cpp)
Install the SDK
Install the gRPC SDK in C++:
- Create and navigate into a new
build
folder in thelattice-sdk-example
project.mkdir build && cd build/
- Use
cmake
to install the Lattice C++ SDK, as configured inCMakeLists.txt
.If successful, this command installs the dependencies, including the Lattice SDK.cmake ..
What's next
- Start building and publishing entities into Lattice.
- Learn how to watch entities, stream specific components, and apply filters.
- See the Lattice sample applications.