I'm trying to cross-compile a rust-ffmpeg example from linux x86_64 to x86_64-pc-windows-gnu, and then execute it.
The compilation process works flawlessly, but then I get errors such as 0158:err:module:import_dll Library avcodec-59.dll (which is needed by L"Z:\\path\\to\\metadata.exe") not found, which pretty explicitly means that the static linking failed.
The command I tried to run is: CARGO_FEATURE_STATIC=foo FFMPEG_DIR=/path/to/precompiled/ffmpeg/windows/ffmpeg cargo build --release --example=metadata --target x86_64-pc-windows-gnu --verbose --features=static
What bugs me is that looking at the rustc execution, it seems that it should work (pasted on an external website because it's hugePast-isserie).
The important part seem to be there: the rust-ffmpeg-sys crate is compiled with
Avcodec is likely not available as static library. Does the ffmpeg install dir contain a file like avcodec.lib? You could also try if not passing FFMPEG_DIR and instead letting it build ffmpeg itself helps.
You're right! I've asked around to the folks at #ffmpeg on libera, and the precompiled shared binaries don't allow to make fully static binaries (or the archives would weigh 500Mb more than what they currently do).
The solution is then to cross-compile ffmpeg myself using --disable-shared and --enable-static, but it is not really realistic.
Anyways, this is not a rust problem, so I'll mark this as solved, but thought maybe future people would be interested in seeing this