> For the complete documentation index, see [llms.txt](https://xrho.gitbook.io/rho/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xrho.gitbook.io/rho/getting-started/building.md).

# Building & Integration

## Prerequisites

* C++17 compiler (GCC 7+, Clang 5+, or equivalent)
* CMake 3.14+
* The [Xi framework](https://github.com/xipid/xic) (placed next to the `rho` directory, or specify with `-DXI_DIR`)

## Building

```bash
# Clone both repos side by side
git clone https://github.com/xipid/xic.git
git clone https://github.com/xipid/rho.git

# Build
cd rho
./build.sh
```

This produces:

* `build/rhod` — The Rho daemon binary
* `build/tests/*` — Test executables

## Using Rho in Your Project

Rho is **header-only**. Add it as a subdirectory in your CMake project:

```cmake
add_subdirectory(path/to/rho)
target_link_libraries(your_target PRIVATE Rho)
```

Or simply add `include/` to your include path and link against Xi:

```cmake
target_include_directories(your_target PRIVATE path/to/rho/include)
target_link_libraries(your_target PRIVATE Xi)
```

## ESP32 (PlatformIO)

Rho compiles on ESP32 with lwIP sockets. The `Bind` class automatically detects the platform:

```cpp
// On ESP32, Bind uses lwip/sockets.h instead of sys/socket.h
// No code changes needed — just include and build
#include <Lines/Bind.hpp>

Bind bind("192.168.1.100:8080");
```

Add both `xic` and `rho` as library dependencies in your `platformio.ini`.

## Compiler Flags

For maximum performance, build with:

```bash
cmake .. -DCMAKE_BUILD_TYPE=Release
```

Rho benefits significantly from inlining and link-time optimization:

```cmake
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -flto -DNDEBUG")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xrho.gitbook.io/rho/getting-started/building.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
