From cea877ca7784aed88240615f36dd2c5c63327fc5 Mon Sep 17 00:00:00 2001 From: Burning_TNT Date: Wed, 30 Sep 2026 00:48:08 +0800 Subject: [PATCH] fix(build): resolve Windows library paths from the crate directory (#2616) When another project uses easytier as a dependency on Windows, linking can fail because the build script emits relative native-library search paths such as easytier/third_party/x86_64/. These paths depend on the consuming project's directory layout instead of locating the libraries bundled with the easytier crate. Build an absolute search path from CARGO_MANIFEST_DIR, followed by third_party and the target architecture directory (x86_64, i686, or arm64). This lets the linker locate the bundled libraries regardless of where the consuming project is built. --- easytier/build/main.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/easytier/build/main.rs b/easytier/build/main.rs index 7cff6847..a46d0569 100644 --- a/easytier/build/main.rs +++ b/easytier/build/main.rs @@ -9,14 +9,20 @@ impl WindowsBuild { pub fn check_for_win() { // add third_party dir to link search path let target = std::env::var("TARGET").unwrap_or_default(); - - if target.contains("x86_64") { - println!("cargo:rustc-link-search=native=easytier/third_party/x86_64/"); + let variant = if target.contains("x86_64") { + "x86_64" } else if target.contains("i686") { - println!("cargo:rustc-link-search=native=easytier/third_party/i686/"); + "i686" } else if target.contains("aarch64") { - println!("cargo:rustc-link-search=native=easytier/third_party/arm64/"); - } + "arm64" + } else { + return; + }; + + let mut path = std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); + path.push("third_party"); + path.push(variant); + println!("cargo:rustc-link-search=native={}", path.to_str().unwrap()); } }