Install
Download your platform's archive, point the compiler at include/ and lib/, and link. medius.h and libmedius_capi serve C and C++ without a Rust toolchain.
DownloadRelease archive per platform
Each platform's archive is on the Releases page.
| Platform | File |
|---|---|
| Windows (64-bit) | medius-capi-x86_64-pc-windows-msvc.tar.gz |
| macOS (Apple Silicon, M1+) | medius-capi-aarch64-apple-darwin.tar.gz |
| macOS (Intel) | medius-capi-x86_64-apple-darwin.tar.gz |
| Linux (Intel/AMD 64-bit) | medius-capi-x86_64-unknown-linux-gnu.tar.gz |
| Linux (ARM64) | medius-capi-aarch64-unknown-linux-gnu.tar.gz |
Inside are two folders:
medius-capi-<your-platform>/
├── include/
│ └── medius.h
└── lib/
└── libmedius_capi (.so Linux · .dylib macOS · .dll + .lib Windows · .a static)Build & run Compiler and linker flags
In the project's Properties (same for C and C++):
- Under C/C++ → General → Additional Include Directories, add the unpacked
include\folder. - Under Linker → General → Additional Library Directories, add the
lib\folder. - Under Linker → Input → Additional Dependencies, add
medius_capi.dll.lib. - Copy
medius_capi.dllnext to your built.exe(or onto yourPATH).
To skip the DLL, add medius_capi.lib in step 3 instead (static, nothing to copy).
From the x64 Native Tools Command Prompt:
cl app.c /I include /link /LIBPATH:lib medius_capi.dll.lib
:: C++: cl /std:c++17 app.cpp /I include /link /LIBPATH:lib medius_capi.dll.lib
:: copy medius_capi.dll next to app.exe, then run:
app.exe# C
cc app.c -I include -L lib -lmedius_capi -o app
# C++ (same header and library)
g++ -std=c++17 app.cpp -I include -L lib -lmedius_capi -o app
# run, with the loader pointed at lib/
LD_LIBRARY_PATH=lib ./app # macOS: DYLD_LIBRARY_PATH=lib ./appOn Linux add -lpthread. Link the static libmedius_capi.a to run without a loader path.
For an unlisted platform, install the Rust toolchain, git clone https://github.com/K4HVH/medius, then cargo build -p medius-capi --release. The library lands in target/release/; the header is medius-capi/include/medius.h. See Build & features.
VerifyVersion print, no box needed
medius_version_string and medius_abi_version are pure library calls. If the version prints, the header and library link and load. On a MEDIUS_ABI_VERSION mismatch, call nothing else and rebuild against the header shipped with the library.
// app.c
#include <stdio.h>
#include <medius.h>
int main(void) {
if (medius_abi_version() != MEDIUS_ABI_VERSION) { /* structs laid out differently */
fprintf(stderr, "library is abi %u, medius.h is abi %u\n",
medius_abi_version(), (unsigned)MEDIUS_ABI_VERSION);
return 1;
}
printf("%s, abi %u\n", medius_version_string(), medius_abi_version());
return 0;
}A linker error (cannot find -lmedius_capi / unresolved external) means the library directory is wrong.
A crash on start (cannot open shared object / a missing-DLL popup) means the loader can't find the library. See Build & features.
ConnectOpen a box, read its version
medius_device_find opens the first box it finds and runs the handshake; medius_device_free closes it. See First program.
MediusDevice *dev = NULL;
if (medius_device_find(&dev) != MEDIUS_STATUS_OK) { /* see Calls & errors */ }
MediusVersion v;
medius_device_query_version(dev, &v);
printf("firmware %u.%u.%u\n", v.fw_major, v.fw_minor, v.fw_patch);
medius_device_free(dev);Every fallible call returns a MediusStatus. Calls & errors covers the failure text; the API index lists every call.