{"id":18300537,"url":"https://github.com/eclipse-zenoh/zenoh-c","last_synced_at":"2026-03-16T12:09:14.319Z","repository":{"id":42372335,"uuid":"235378028","full_name":"eclipse-zenoh/zenoh-c","owner":"eclipse-zenoh","description":"C API for Zenoh","archived":false,"fork":false,"pushed_at":"2024-10-29T08:59:44.000Z","size":16881,"stargazers_count":75,"open_issues_count":48,"forks_count":56,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-29T09:55:45.952Z","etag":null,"topics":["edge-computing","iot","messaging","micro-controllers","networking","robotics","ros2"],"latest_commit_sha":null,"homepage":"http://zenoh.io","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eclipse-zenoh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-21T15:41:23.000Z","updated_at":"2024-10-29T00:53:41.000Z","dependencies_parsed_at":"2023-09-22T15:01:46.634Z","dependency_job_id":"a750b600-1ddc-4a38-86db-28fcf2ef0e6f","html_url":"https://github.com/eclipse-zenoh/zenoh-c","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipse-zenoh%2Fzenoh-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eclipse-zenoh","download_url":"https://codeload.github.com/eclipse-zenoh/zenoh-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276164,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["edge-computing","iot","messaging","micro-controllers","networking","robotics","ros2"],"created_at":"2024-11-05T15:12:45.589Z","updated_at":"2026-03-16T12:09:14.311Z","avatar_url":"https://github.com/eclipse-zenoh.png","language":"Rust","funding_links":[],"categories":["Official API"],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/eclipse-zenoh/zenoh/main/zenoh-dragon.png\" height=\"150\"\u003e\n\n[![CI](https://github.com/eclipse-zenoh/zenoh-c/workflows/CI/badge.svg)](https://github.com/eclipse-zenoh/zenoh-c/actions?query=workflow%3A%22CI%22)\n[![Documentation Status](https://readthedocs.org/projects/zenoh-c/badge/?version=latest)](https://zenoh-c.readthedocs.io/en/latest/?badge=latest)\n[![Discussion](https://img.shields.io/badge/discussion-on%20github-blue)](https://github.com/eclipse-zenoh/roadmap/discussions)\n[![Discord](https://img.shields.io/badge/chat-on%20discord-blue)](https://discord.gg/2GJ958VuHs)\n[![License](https://img.shields.io/badge/License-EPL%202.0-blue)](https://choosealicense.com/licenses/epl-2.0/)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n# Eclipse Zenoh\n\nThe Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query and Compute.\n\nZenoh (pronounce _/zeno/_) unifies data in motion, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.\n\nCheck the website [zenoh.io](http://zenoh.io) and the [roadmap](https://github.com/eclipse-zenoh/roadmap) for more detailed information.\n\n-------------------------------\n\n# C API\n\nThis repository provides a C binding based on the main [Zenoh implementation written in Rust](https://github.com/eclipse-zenoh/zenoh).\n\n-------------------------------\n\n## How to build it\n\n1. Make sure that [Rust](https://www.rust-lang.org) is available on your platform.\n   Please check [here](https://www.rust-lang.org/tools/install) to learn how to install it.\n   If you already have the Rust toolchain installed, make sure it is up-to-date with:\n\n   ```bash\n   rustup update\n   ```\n\n2. Clone the [source] with `git`:\n\n   ```bash\n   git clone https://github.com/eclipse-zenoh/zenoh-c.git\n   ```\n\n   [source]: https://github.com/eclipse-zenoh/zenoh-c\n\n3. Build:\n\n   Good CMake practice is to perform build outside of source directory, leaving source tree untouched. The examples below demonstrates this mode of building. On the other hand VScode by default creates build directory named 'build' inside source tree. In this case build script slightly changes its behavior. See more about it in section 'VScode'.\n\n   By default build configuration is set to `Release`, it's not necessary to add `-DCMAKE_BUILD_TYPE=Release` option on configuration step. But if your platform uses multi-config generator by default (this is the case on Windows), you may need to add option `--config Release` on build step. See more in CMake [build-configurations] documentation. Option`--config Release` is skipped in further examples for brewity. It's actually necessary for [Visual Studio generators] only. For [Ninja Multi-Config] the build script is able to select `Release` as the default configuration.\n\n   ```bash\n   mkdir -p build \u0026\u0026 cd build \n   cmake ../zenoh-c\n   cmake --build . --config Release\n   ```\n\n   The generator to use is selected with option `-G`. If Ninja is installed on your system, adding `-GNinja` to `cmake` command can greatly speed up the build time:\n\n   ```bash\n   cmake ../zenoh-c -GNinja\n   cmake --build .\n   ```\n\n   Unstable api and/or shared memory support can be enabled by setting repectively `ZENOHC_BUILD_WITH_UNSTABLE_API` and `ZENOHC_BUILD_WITH_SHARED_MEMORY` Cmake flags to `true` during configuration step.\n\n   ```bash\n   cmake -DZENOHC_BUILD_WITH_UNSTABLE_API=true -DZENOHC_BUILD_WITH_SHARED_MEMORY=true ../zenoh-c\n   cmake --build . --config Release\n   ```\n\n   [build-configurations]: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#build-configurations\n   [Visual Studio generators]: https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#id14\n   [Ninja Multi-Config]: https://cmake.org/cmake/help/latest/generator/Ninja%20Multi-Config.html\n\n4. Install:\n\n   To install zenoh-c library into system just build target `install`. You need root privileges to do it, as the default install location is `/usr/local`.\n\n   ```bash\n   cmake --build . --target install\n   ```  \n\n   If you want to install zenoh-c libraries locally, you can set the installation directory with `CMAKE_INSTALL_PREFIX`\n\n   ```bash\n   cmake ../zenoh-c -DCMAKE_INSTALL_PREFIX=~/.local\n   cmake --build . --target install\n   ```\n\n   By default only dynamic library is built and installed. Set `BUILD_SHARED_LIBS` variable to false to build and install static library:\n\n   ```bash\n   cmake ../zenoh-c -DCMAKE_INSTALL_PREFIX=~/.local -DBUILD_SHARED_LIBS=FALSE\n   cmake --build . --target install\n   ```\n\n   The result of installation is the header files in `include` directory, the library files in `lib` directory and cmake package configuration files for package `zenohc` in `lib/cmake` directory. The library later can be loaded with CMake command `find_package(zenohc)`.\n   Add dependency in CMakeLists.txt on target\n\n   - `zenohc::shared` for linking dynamic library\n   - `zenohc::static` for linking static library\n   - `zenohc::lib` for linking static or dynamic library depending on boolean variable `BUILD_SHARED_LIBS`\n\n5. VScode\n\n   When zenoh-c project is opened in VSCode the build directory is set to `build` inside source tree (this is default behavior of Microsoft [CMake Tools]). The project build script detects this situation. In this case it places build files in `target` directory and `Cargo.toml` file (which is generated from `Cargo.toml.in`) into the root of source tree, as the rust developers used to and as the rust build tools expects by default. This behavior also can be explicitly enabled by setting `ZENOHC_BUILD_IN_SOURCE_TREE` variable to `TRUE`.\n\n   [CMake Tools]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools\n\n## Building the Examples\n\nThe examples can be built in two ways. One is to select `examples` as a build target of zenoh-c project (assuming here that the current directory is side-by-side with zenoh-c directory):\n\n```bash\ncmake ../zenoh-c\ncmake --build . --target examples\n```\n\nYou may also use `--target \u003cexample_name\u003e` if you wish to only build a specific example.\n\nAll build artifacts will be in the `target/release/examples` directory in this case.\n\nThe second way is to directly build `examples` as a root project:\n\n```bash\ncmake ../zenoh-c/examples\ncmake --build .\n```\n\nLink with `zenoh-c` installed into default location in the system (with [find_package]):\n\n```bash\ncmake ../zenoh-c/examples\n```\n\nLink with `zenoh-c` installed in `~/.local` directory:\n\n```bash\ncmake ../zenoh-c/examples -DCMAKE_INSTALL_PREFIX=~/.local\n```\n\n## Running the Examples\n\nSee information about running examples [here](./examples/README.md).\n\n## Documentation\n\nZenoh-c API documentation is available on [Read the Docs](https://zenoh-c.readthedocs.io/en/latest/index.html).\n\nIt can be built manually by performing the following steps:\n\n```bash\ncd docs\ndoxygen\nsphinx-build -b html . _build/html\n```\n\n## Cross-Compilation\n\nCross-compilation can be performed using standard cmake approach as described in [[cmake-toolchains](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html)].\n\nIn addition the following project-specific options might need to be set for cross-compilation:\n\n- `-DZENOHC_CARGO_CHANNEL=\"+nightly\"|\"+beta\"|\"+stable\"`: refers to a specific rust toolchain release [[rust-channels](https://rust-lang.github.io/rustup/concepts/channels.html)]\n- `-DZENOHC_CARGO_FLAGS`: several optional flags can be used for compilation. [[cargo flags](https://doc.rust-lang.org/cargo/commands/cargo-build.html)]\n- `-DZENOHC_CUSTOM_TARGET`: specifies a crosscompilation target. Currently rust support several Tier-1, Tier-2 and Tier-3 targets [[targets](https://doc.rust-lang.org/nightly/rustc/platform-support.html)].\n\nLet's put all together in an example:\nAssuming you want to cross-compile for x86_64-pc-windows-gnu from Ubuntu environment.\n\n1. Install required packages\n   - `sudo apt-get install -y mingw-w64`: cross-compilation toolchain for c/c++.\n   - `rustup toolchain install x86_64-pc-windows-gnu`: cross-compilation toolchain for rust.\n2. *(Only if you're using `nightly`)\n   - `rustup component add rust-src --toolchain nightly`\n3. Compile Zenoh-C. Assume that it's in `zenoh-c` directory. Notice that build in this sample is performed outside of source directory\n\n   ```bash\n   export RUSTFLAGS=\"-Clinker=x86_64-w64-mingw32-gcc -Car=x86_64-w64-mingw32-ar\"\n   mkdir -p build \u0026\u0026 cd build\n   cmake ../zenoh-c  -DCMAKE_SYSTEM_NAME=\"Windows\" -DCMAKE_C_COMPILER=\"x86_64-w64-mingw32-gcc\" -DCMAKE_CXX_COMPILER=\"x86_64-w64-mingw32-g++\" -DCMAKE_SYSTEM_PROCESSOR=\"x86_64\" -DZENOHC_CARGO_CHANNEL=\"+nightly\" -DZENOHC_CARGO_FLAGS=\"-Zbuild-std=std,panic_abort\" -DZENOHC_CUSTOM_TARGET=\"x86_64-pc-windows-gnu\" -DCMAKE_INSTALL_PREFIX=\"../x86_64-pc-windows-gnu/stage\"\n   cmake --build . --target install\n   ```\n\nIf all goes right the building files will be located at:\n`/path/to/zenoh-c/target/x86_64-pc-windows-gnu/release`\nand release files will be located at\n`/path/to/zenoh-c/target/x86_64-pc-windows-gnu/release`\n\n\u003e :warning: **WARNING** :warning: : Perhaps additional efforts are necessary, that will depend of your environment.\n\n## Rust Version\n\nThe minimal supported Rust version (MSRV) is 1.75, as specified in [Cargo.toml](Cargo.toml).\nBuilds and tests are run using the version defined in [rust-toolchain.toml](rust-toolchain.toml).\nThe rust version can be specified with CMake variable `ZENOHC_CARGO_CHANNEL`:\n\n```bash\ncmake ../zenoh-c -DZENOHC_CARGO_CHANNEL=\"+1.75.0\"\n```\n\nor\n\n```bash\ncmake ../zenoh-c -DZENOHC_CARGO_CHANNEL=\"+nightly\"\n```\n\nSpecial efforts are made to keep Rust 1.75 compatibility. The base `zenoh` project provides crate [zenoh-pinned-deps-1-75](https://crates.io/crates/zenoh-pinned-deps-1-75) which\npins crate dependencies to latest versions compatible with rust 1.75. This crate is separate from the [zenoh](https://crates.io/crates/zenoh) itself to avoid staying on obsolete versions and crate version conflicts.\nIf some project needs compatibility with Rust 1.75, it adds a dependency on `zenoh-pinned-deps-1-75` and if necessary adds some additional version pins (like `crate_name=\"=X.Y.Z\"`).\nOn the `zenoh-c` level there is a special check in `CMakeLists.txt` which uncomments pinning in the generated `Cargo.toml` when `ZENOHC_CARGO_CHANNEL` == `+1.75.0`.\n\n## Zenoh features support (enabling/disabling protocols, etc)\n\nIt's necessary sometimes to build zenoh-c library with set of features different from default. For example: enable TCP and UDP only. This can be done by changing `ZENOHC_CARGO_FLAGS` parameter for cmake (notice \";\" instead of space due to cmake peculiarities)\n\nAvailable features can be found in [Cargo.toml](./Cargo.toml)\n\n```bash\ncmake ../zenoh-c -DZENOHC_CARGO_FLAGS=\"--no-default-features;--features=transport_tcp,transport_udp\"\n```\n\n## Versioning\n\nBeing a CMake project, zenoh-c is limited to the `MAJOR.MINOR.PATCH.TWEAK` version scheme [inherent\nto CMake](https://gitlab.kitware.com/cmake/cmake/-/issues/16716). However, zenoh-c also incorporates\na Cargo package which cannot be versionned with the `MAJOR.MINOR.PATCH.TWEAK` version scheme (not\nSemVer compatible). Hence zenoh-c uses a one-to-one mapping between CMake versions and SemVer versions:\n\n| CMake version           | SemVer equivalent | Meaning              |\n|-------------------------|-------------------|----------------------|\n| `1.2.3`                 | `1.2.3`           | Release version      |\n| `1.2.3.0`               | `1.2.3-dev`       | Developement version |\n| `1.2.3.x if x \u003e= 1`     | `1.2.3-pre.x`     | Pre-release version  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-zenoh%2Fzenoh-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feclipse-zenoh%2Fzenoh-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipse-zenoh%2Fzenoh-c/lists"}