From c5b1b38ec00a037d411df02af132ced5a53e15d9 Mon Sep 17 00:00:00 2001 From: Oleg Andreev Date: Mon, 4 Oct 2021 20:19:06 +0300 Subject: [PATCH] Added extra libraries to link for Android static build (you still need to bundle hidapi yourselves as it is build in shared mode). --- sdl2-sys/build.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sdl2-sys/build.rs b/sdl2-sys/build.rs index ee99da89..fd54fb49 100644 --- a/sdl2-sys/build.rs +++ b/sdl2-sys/build.rs @@ -257,6 +257,13 @@ fn link_sdl2(target_os: &str) { println!("cargo:rustc-link-lib=framework=AudioToolbox"); println!("cargo:rustc-link-lib=framework=Metal"); println!("cargo:rustc-link-lib=iconv"); + } else if target_os == "android" { + println!("cargo:rustc-link-lib=android"); + println!("cargo:rustc-link-lib=dl"); + println!("cargo:rustc-link-lib=GLESv1_CM"); + println!("cargo:rustc-link-lib=GLESv2"); + println!("cargo:rustc-link-lib=hidapi"); + println!("cargo:rustc-link-lib=log"); } else { // TODO: Add other platform linker options here. } @@ -475,7 +482,8 @@ fn main() { link_sdl2(target_os); - #[cfg(all(feature = "bundled", not(feature = "static-link")))] + // Android builds shared libhidapi.so even for static builds. + #[cfg(all(feature = "bundled", any(not(feature = "static-link"), target_os = "android")))] { copy_dynamic_libraries(&sdl2_compiled_path, target_os); }