Since I don’t actually have a ton of time to investigate a potential problem (i.e. a potential non-problem), it would be best if you could distill your implementation down to a simple reproducible example that’s not intertwined with `gifski::Collector`, `BinResult`, etc. Then I could take a look.
I finally tried this. It's pretty nice to be able to build against a managed FFmpeg installation, rather than an ad-hoc one. I would have considered this the goto method, such a shame that vcpkg's FFmpeg is on 4.2, one year out of date...
Two things:
1. I'd rather have `VCPKGRS_DYNAMIC` set automatically, since the presence of `static` or lack thereof is a clear enough signal of intent. So something like
```diff
diff --git a/build.rs b/build.rs
index 32cf00f..a81c14b 100644
--- a/build.rs
+++ b/build.rs
@@ -350,7 +350,10 @@ fn try_vcpkg() -> Option<Vec<PathBuf>> {
}
#[cfg(target_env = "msvc")]
-fn try_vcpkg() -> Option<Vec<PathBuf>> {
+fn try_vcpkg(statik: bool) -> Option<Vec<PathBuf>> {
+ if !statik {
+ env::set_var("VCPKGRS_DYNAMIC", "1");
+ }
vcpkg::find_package("ffmpeg")
.map_err(|e| {
println!("Could not find ffmpeg with vcpkg: {}", e);
@@ -612,16 +615,7 @@ fn main() {
);
link_to_libraries(statik);
vec![ffmpeg_dir.join("include")]
- } else if let Some(paths) = try_vcpkg() {
- let is_vcpkg_static = env::var_os("VCPKGRS_DYNAMIC").is_none();
- if is_vcpkg_static != statik {
- panic!(
- "vcpkg settings do not match ffmpeg-sys settings: VCPKGRS_DYNAMIC is {}, but ffmpeg-sys static feature is {}",
- if is_vcpkg_static { "not defined, which means that vcpkg libraries are linked statically" } else { "defined" },
- if statik { "specified" } else { "not specified "}
- );
- }
-
+ } else if let Some(paths) = try_vcpkg(statik) {
// vcpkg doesn't detect the "system" dependencies
if statik {
if cfg!(feature = "avcodec") || cfg!(feature = "avdevice") {
```
2. (I'm a Unix guy with a Windows machine on the side but little to no knowledge of Windows development, so please bear with me.) I tried static linking and it works well. But I couldn't get dynamic linking to work.
Consider building an example program from [zmwangx/rust-ffmpeg](https://github.com/zmwangx/rust-ffmpeg):
```
cargo build --no-default-features --features ffmpeg42,codec,format --example metadata
```
Now when I execute `.\target\debug\examples\metadata` I get -1073741515 `STATUS_DLL_NOT_FOUND`. And Dependency Walker says I'm missing a whole bunch of DLLs, including `AVCODEC`, `AVFORMAT` and `AVUTIL`.

Any idea what's going wrong here? My Rust toolchain:
```console
$ rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\zmwang\.rustup
stable-x86_64-pc-windows-msvc (default)
rustc 1.45.1 (c367798cf 2020-07-26)
```