Skip to content

cmake: add AUDIOCPP_BUILD_C_API_STATIC option for embedding (libaudiocpp.a) - #1290

Merged
0xShug0 merged 2 commits into
0xShug0:mainfrom
codixor:static-libaudiocpp
Nov 14, 2026
Merged

0xShug0 merged 2 commits into
0xShug0:mainfrom
codixor:static-libaudiocpp

Conversation

@codixor

@codixor codixor commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1287.

Adds an opt-in CMake option AUDIOCPP_BUILD_C_API_STATIC (default OFF) that builds the C ABI as a static library (libaudiocpp.a, output bin/libaudiocpp.a) alongside the existing shared target, for embedding into Rust/FFI binaries.

  • New target audiocpp_static built from src/capi/audiocpp.cpp
  • Links engine_runtime + ggml; OpenMP honored when ENGINE_ENABLE_OPENMP=ON (otherwise the static lib would pull _kmpc* symbols into consumers)
  • POSITION_INDEPENDENT_CODE ON, ARCHIVE_OUTPUT_DIRECTORY pointing at the build bin dir

Verified: cmake -B build -DAUDIOCPP_BUILD_C_API=ON -DAUDIOCPP_BUILD_C_API_STATIC=ON -DENGINE_ENABLE_OPENMP=OFF builds bin/libaudiocpp.a cleanly, and an embedding Rust crate links against it.

red-team review flag: CMake-only change, no C++ source changes; no new dependencies.

@0xShug0

0xShug0 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codixor Thanks for the PR! Please fix the two issues below:

  1. Windows library-name collision: The shared target’s import library and the new static archive both produce bin/audiocpp.lib under MSVC. Please give the static archive a distinct name.

  2. Missing version definition: The new target omits AUDIOCPP_VERSION_STRING, so audiocpp_build_version() returns "unknown" when using the static library.

@codixor

codixor commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review — both points are fixed.

  1. Windows name collision — the static archive now keeps libaudiocpp.a on Linux/macOS (that's what our embedder resolves) but is emitted as audiocpp_static.lib under MSVC, so it can't collide with the shared target's import library.
  2. Version define — the static target now gets AUDIOCPP_VERSION_STRING exactly like the shared one, so audiocpp_build_version() reports the real version instead of "unknown".

Re-verified the Linux static build: libaudiocpp.a lands in bin/ and links into our Rust worker cleanly. I can't build-test MSVC from here, so the audiocpp_static name is by convention — happy to change it if you'd prefer something else.

@0xShug0
0xShug0 merged commit 3a08299 into 0xShug0:main Nov 14, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codixor PR merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support a static libaudiocpp for embedding (C-API)

2 participants