Skip to content

Commit 0bca8df

Browse files
authored
Merge pull request #1796 from bet4it/dylib
Fix dynamic linkage on msvc
2 parents ba92f79 + 243e9c8 commit 0bca8df

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bindings/rust/build.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ fn build_with_cmake() {
138138

139139
// Lazymio(@wtdcode): Dynamic link may break. See: https://github.com/rust-lang/cargo/issues/5077
140140
if cfg!(feature = "dynamic_linkage") {
141-
println!("cargo:rustc-link-lib=dylib=unicorn");
141+
if compiler.is_like_msvc() {
142+
println!("cargo:rustc-link-lib=dylib=unicorn-import");
143+
} else {
144+
println!("cargo:rustc-link-lib=dylib=unicorn");
145+
}
142146
} else {
143147
println!("cargo:rustc-link-lib=static=unicorn");
144148
}
@@ -159,7 +163,11 @@ fn main() {
159163
println!("cargo:rustc-link-search=native={}", dir.to_str().unwrap());
160164
}
161165
if cfg!(feature = "dynamic_linkage") {
162-
println!("cargo:rustc-link-lib=dylib=unicorn");
166+
if cc::Build::new().get_compiler().is_like_msvc() {
167+
println!("cargo:rustc-link-lib=dylib=unicorn-import");
168+
} else {
169+
println!("cargo:rustc-link-lib=dylib=unicorn");
170+
}
163171
} else {
164172
println!("cargo:rustc-link-arg=-Wl,-allow-multiple-definition");
165173
println!("cargo:rustc-link-lib=static=unicorn");

0 commit comments

Comments
 (0)