alexcrichton / curl-rust

Rust bindings to libcurl
MIT License
1k stars 234 forks source link

Add the ability to use pkg_config instead of vcpkg when building with mingw64 on Windows #484

Open lepapareil opened 1 year ago

lepapareil commented 1 year ago

Hi @alexcrichton, and many thks for your work 😀.

I am having the same need as @ian-p-cooke had 4 years ago 👉 https://github.com/alexcrichton/curl-rust/issues/221. I decided to use mingw64 to build curl-4.dll on Windows instead of vcpkg. It works as expected following these steps:

Then I build my rust app with crate-sys dependency with these prerequisites:

I expected curl-sys to link my mingw64/curl-4.dll, but it does not permit the use of mingw64's pkg_config. Instead, the crate uses embedded curl 7.86-DEV as mentioned in documentation.

So, to achieve my goal, I had to update curl-sys/build.rs line 38 like this:

if windows {
  if try_vcpkg() {
    return;
    } else if try_pkg_config() {
        return;
      }
  } else if try_pkg_config() {
    return;
  }
}

With this update, curl-sys correctly links my rust app with my fresh mingw64/curl-4.dll.

Now that compiling curl with mingw64 is working easily, I think that we could allow curl-sys to use pkg_config instead of vcpkg according to the dev's choice.