From 8e40ba009a321d10bee2844bfc455c8362059f83 Mon Sep 17 00:00:00 2001 From: Deyan Ginev Date: Sun, 12 Jul 2026 15:00:07 -0400 Subject: [PATCH 1/2] vcpkg arm: link Windows SDK system libs (bcrypt, ws2_32) The vcpkg crate emits link directives for the port's libraries and port dependencies, but not for Windows SDK system libraries (Libs.private in libxml-2.0.pc). libxml2 >= 2.12 calls BCryptGenRandom from xmlInitRandom (dict.c), leaving an unresolved external when linking the static libxml2.lib into a proc-macro/bin/test target; ws2_32 likewise backs nanohttp. Both import libs ship with every MSVC toolchain. Witnessed in latexml-oxide's Windows port: LNK2019 BCryptGenRandom in latexml_codegen's proc-macro dylib link. Co-Authored-By: Claude Fable 5 --- build.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build.rs b/build.rs index 63af295ea..4a1d5b9b2 100644 --- a/build.rs +++ b/build.rs @@ -138,6 +138,17 @@ mod vcpkg_dep { use crate::ProbedLib; pub fn vcpkg_find_libxml2() -> Option { if let Ok(metadata) = vcpkg::Config::new().find_package("libxml2") { + // vcpkg emits link directives for the port's own libraries and its + // port dependencies (iconv, zlib, ...), but NOT for Windows SDK + // system libraries, which are Libs.private in libxml-2.0.pc: + // libxml2 >= 2.12 calls BCryptGenRandom (xmlInitRandom, dict.c), so + // a static libxml2.lib leaves that symbol unresolved unless we link + // bcrypt ourselves. ws2_32 likewise backs the (default-on) nanohttp + // code. Both import libraries ship with every MSVC/Windows SDK + // toolchain, so linking them unconditionally here is safe even for + // vcpkg builds configured without those features. + println!("cargo:rustc-link-lib=bcrypt"); + println!("cargo:rustc-link-lib=ws2_32"); let include_paths = metadata .include_paths .into_iter() From 1ca81c10bf3b204993e2551debf28a1c40f59f09 Mon Sep 17 00:00:00 2001 From: Deyan Ginev Date: Sun, 12 Jul 2026 18:56:38 -0400 Subject: [PATCH 2/2] release prep: 0.3.16 + changelog entry for the vcpkg system-libs fix Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 12 ++++++++++++ Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c1ad146b..25c4a194f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## [Unreleased] +## [0.3.16] (2026-07-12) + +### Fixed + +* Windows/MSVC vcpkg builds: emit `cargo:rustc-link-lib=bcrypt` and `ws2_32` + alongside the vcpkg-resolved libraries. vcpkg emits link directives for the + port's libraries and port dependencies but not for Windows SDK system + libraries (`Libs.private` in `libxml-2.0.pc`); libxml2 >= 2.12 calls + `BCryptGenRandom` from `xmlInitRandom`, so linking a static `libxml2.lib` + into any real target (proc-macro dylib, bin, test) failed with LNK2019. + Both import libraries ship with every MSVC/Windows SDK toolchain. + ## [0.3.15] (2026-07-06) ### Added diff --git a/Cargo.toml b/Cargo.toml index bbb3d5ce8..d187261e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libxml" -version = "0.3.15" +version = "0.3.16" edition = "2024" rust-version = "1.88" authors = ["Andreas Franzén ", "Deyan Ginev ","Jan Frederik Schaefer "]