| Crates.io | libopus_sys |
| lib.rs | libopus_sys |
| version | 0.3.3 |
| created_at | 2024-11-18 11:09:09.134468+00 |
| updated_at | 2026-01-14 15:38:21.57641+00 |
| description | FFI-Binding to Opus, dynamically or statically linked for Windows and UNIX. |
| homepage | |
| repository | https://github.com/cijiugechu/libopus_sys.git |
| max_upload_size | |
| id | 1452102 |
| size | 15,056,468 |
libopus_syslibopus_sys is an FFI-Rust-binding to Opus version 1.5.
Originally, this sys-crate was made to empower the serenity-crate to build audio features on Windows, Linux, and macOS. However, it's not limited to that.
Everyone is welcome to contribute,
check out the CONTRIBUTING.md for further guidance.
This crate can either:
libopus, orlibopus required) via the bundled feature.bundled: build Opus from the vendored opus/ sources using CMake (does not require a system libopus)static: prefer static linkingdynamic: prefer dynamic linkinggenerate_binding: regenerate src/lib.rs from src/wrapper.h (requires libclang)--features bundled): you need cmake.pkg-config (Unix / GNU targets only).Clang and LIBCLANG_PATH.If you want a build that does not depend on any system-installed libopus, enable bundled:
cargo build --features bundled
You can also force this via environment variables:
OPUS_BUNDLED=1LIBOPUS_BUNDLED=1When bundled is enabled, the build script uses CMake to compile the vendored opus/ sources and
links the resulting library.
libopus_sys targets Opus 1.5 and supports Windows, Linux, and macOS.
musl targets.gnu targets.You can override this with features:
--features static--features dynamicIf both are enabled, we pick the default for your target (as described above).
Environment variables LIBOPUS_STATIC or OPUS_STATIC take precedence over features: if either
is set, static linking is selected (the value does not matter).
bundled is not enabled)On Unix / GNU targets, the build script will:
pkg-config for opus (unless LIBOPUS_NO_PKG or OPUS_NO_PKG is set)LIBOPUS_LIB_DIR or OPUS_LIB_DIR is set, link from that prefixopus/) are present, build Opus via CMakeIf none of these work, the build fails with instructions on how to proceed.
On Unix / GNU targets (and when bundled is not enabled), libopus_sys will try pkg-config
first. Set LIBOPUS_NO_PKG=1 or OPUS_NO_PKG=1 to bypass it.
If you prefer to link an existing libopus installation (or you already ship one with your
application), you can point the build script at it:
LIBOPUS_LIB_DIR=/path/to/prefixOPUS_LIB_DIR=/path/to/prefixWhere /path/to/prefix contains lib/ (e.g. /usr/local, a Homebrew prefix, etc.).
Be aware that using an Opus other than version 1.5 may not work.
If you want to generate the binding yourself, you can use the
generate_binding-feature.
Be aware, bindgen requires Clang and its LIBCLANG_PATH
environment variable to be specified.
Add this to your Cargo.toml:
[dependencies]
libopus_sys = "0.3"