#build-dependencies #windows #ffi #win32

vcpkg

A library to find native dependencies in a vcpkg tree at build time in order to be used in Cargo build scripts.

16 releases

0.2.4 Jun 14, 2018
0.2.3 Apr 12, 2018
0.2.2 Jun 15, 2017
0.2.0 May 16, 2017
0.0.2 Apr 22, 2017

#4 in Windows APIs

Download history 7301/week @ 2018-05-06 9954/week @ 2018-05-13 12359/week @ 2018-05-20 9755/week @ 2018-05-27 9983/week @ 2018-06-03 9399/week @ 2018-06-10 8206/week @ 2018-06-17 9491/week @ 2018-06-24 10885/week @ 2018-07-01 10092/week @ 2018-07-08 11424/week @ 2018-07-15 12167/week @ 2018-07-22 9813/week @ 2018-07-29

37,527 downloads per month


lib.rs:

A build dependency for Cargo libraries to find libraries in a Vcpkg tree. From a Vcpkg package name this build helper will emit cargo metadata to link it and it's dependencies (excluding system libraries, which it cannot derive).

Note: You must set one of RUSTFLAGS=-Ctarget-feature=+crt-static or VCPKGRS_DYNAMIC=1 in your environment or the vcpkg-rs helper will not find any libraries. If VCPKGRS_DYNAMIC is set, cargo install will generate dynamically linked binaries, in which case you will have to arrange for dlls from your Vcpkg installation to be available in your path.

The simplest possible usage looks like this :-

vcpkg::find_package("libssh2").unwrap();

The cargo metadata that is emitted can be changed like this :-

vcpkg::Config::new()
    .emit_includes(true)
    .find_package("zlib").unwrap();

If the search was successful all appropriate Cargo metadata will be printed to stdout.

The decision to choose static variants of libraries is driven by adding RUSTFLAGS=-Ctarget-feature=+crt-static to the environment. This requires at least Rust 1.19.

A number of environment variables are available to globally configure which libraries are selected.

  • VCPKG_ROOT - Set the directory to look in for a vcpkg installation. If it is not set, vcpkg will use the user-wide installation if one has been set up with vcpkg integrate install

  • VCPKGRS_NO_FOO - if set, vcpkg-rs will not attempt to find the library named foo.

  • VCPKGRS_DISABLE - if set, vcpkg-rs will not attempt to find any libraries.

  • VCPKGRS_DYNAMIC - if set, vcpkg-rs will link to DLL builds of ports.

There is a companion crate vcpkg_cli that allows testing of environment and flag combinations.

C:\src> vcpkg_cli probe -l static mysqlclient
Found library mysqlclient
Include paths:
        C:\src\[..]\vcpkg\installed\x64-windows-static\include
Library paths:
        C:\src\[..]\vcpkg\installed\x64-windows-static\lib
Cargo metadata:
        cargo:rustc-link-search=native=C:\src\[..]\vcpkg\installed\x64-windows-static\lib
        cargo:rustc-link-lib=static=mysqlclient
MIT/Apache-2.0 license
  • No runtime deps

Reverse deps