Skip to content

fix: export opus and shim symbols from Windows DLL #53

Merged
SineVector241 merged 2 commits intoAvionBlock:masterfrom
towneh:master
Apr 10, 2026
Merged

fix: export opus and shim symbols from Windows DLL #53
SineVector241 merged 2 commits intoAvionBlock:masterfrom
towneh:master

Conversation

@towneh
Copy link
Copy Markdown
Contributor

@towneh towneh commented Apr 10, 2026

Problem

On Windows, MSVC link does not automatically export symbols from static
libraries into a DLL (unlike Linux --whole-archive or macOS -force_load).
This resulted in opus.dll having zero exports, causing P/Invoke failures
at runtime.

Changes

  • opus_shim.c: Added SHIM_EXPORT macro (__declspec(dllexport) on
    Windows, no-op elsewhere) to all opussharp_* shim functions so they are
    explicitly exported from the DLL.

  • OpusCompile.yml (Windows build step): Generate a .def file from
    dumpbin /symbols output listing all opus_* symbols from the static lib,
    then pass /DEF:opus.def to the linker so those symbols are also exported.
    This replaces the non-functional /WHOLEARCHIVE approach.

Verification

Built and tested via CI:
https://github.com/towneh/OpusSharp/actions/runs/24208499689
Resulting All-Runtimes.zip was successfully imported into the Basis Unity
project and confirmed working on Windows and macOS. Successfully build Android APK with runtime.

towneh added 2 commits April 9, 2026 13:58
… exported

Without /WHOLEARCHIVE, MSVC link does not export symbols from the static
opus.lib into the DLL, resulting in a DLL with zero exports. Linux and
macOS already used --whole-archive/-force_load equivalents.
MSVC link does not auto-export symbols from static libs into DLLs
(unlike Linux --whole-archive / macOS -force_load). Two changes fix this:

- Add SHIM_EXPORT (__declspec(dllexport) on Windows) to all opussharp_*
  functions in opus_shim.c so they are exported from the DLL.
- Generate a .def file from dumpbin /symbols output in the CI Windows
  build step, listing all opus_* symbols from the static lib, so they
  are also exported. Replaces the non-functional /WHOLEARCHIVE flag.
@SineVector241 SineVector241 merged commit 9a0d23e into AvionBlock:master Apr 10, 2026
4 checks passed
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.

2 participants