STTNet 0.7.0

Chapter 2: Download, Build, Run

This chapter provides the complete commands for dependency installation, cloning, CMake build, launch, and curl verification.

1. Dependencies

sudo apt-get update
sudo apt-get install -y build-essential cmake pkg-config libjsoncpp-dev libssl-dev

2. Clone the repository

git clone https://github.com/StephenTaam/STTNet.git
cd STTNet

3. Build Configuration

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
  -DSTTNET_BUILD_EXAMPLE=ON \
  -DSTTNET_BUILD_TESTS=OFF \
  -DSTTNET_BUILD_BENCHMARK=OFF
cmake --build build --parallel

4. Execution and Expected Result

./build/examples/sttnet_http_hello
# In another terminal:
curl -i http://127.0.0.1:8080/ping
Expected: HTTP 200 with body pong. Ctrl-C follows the synchronous signal-wait path and produces a clean shutdown.

5. Common failures

SymptomLikely Cause and Resolution
json/json.h not foundThe libjsoncpp-dev package is required; reconfiguration uses a clean build directory.
OpenSSL not foundThe libssl-dev package and selected library architecture match the build environment.
Bind failedPort binding requires an unused port; unprivileged users normally use ports 1024 or higher.
Built but cannot startRelevant diagnostics are available in stderr/logs, certificate paths, permissions, port settings, and fd limits.

6. Link STTNet into your CMake project

add_subdirectory(third_party/STTNet)
add_executable(my_server main.cpp)
target_link_libraries(my_server PRIVATE STTNet::sttnet)