How to statically link ffmpeg with the ac-ffmpeg crate

Hi,

I'm trying to use the ac-ffmpeg crate in a hobby project but I'm having trouble statically linking ffmpeg, both on Windows and MacOS. I'm not 100% sure which files I need but for windows I downloaded the "ffmpeg-5.1-windows-desktop-vs2022-gpl-lite.7z" archive from here and extracted it to a folder /ext/ in my project root. I then added this .cargo/config.toml file:

[env]
FFMPEG_INCLUDE_DIR = { value = "ext/ffmpeg-5.1-windows-desktop-clang-gpl-lite/include", relative = true}
FFMPEG_LIB_DIR = { value = "ext/ffmpeg-5.1-windows-desktop-clang-gpl-lite/lib", relative = true }
FFMPEG_STATIC = "1"

[target.x86_64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

Both on Windows and MacOS I am able to build with cargo build --release but when I try to run with cargo run --release on Windows I get the error

error: process didn't exit successfully: `target\release\ac-ffmpeg-test.exe` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)

and on MacOS

dyld[10454]: symbol not found in flat namespace (_kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms)
[1]    10454 abort      cargo run --release

This is my first timing linking to C dependencies but to me it looks like it didn't actually link the libraries. I tried searching online for these errors but I was not able to find what to try next. Maybe someone here knows? Thanks.

I created a simple test repository here.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.