diff --git a/lsl-sys/build.rs b/lsl-sys/build.rs index 0747fa8..cf8e654 100644 --- a/lsl-sys/build.rs +++ b/lsl-sys/build.rs @@ -35,12 +35,27 @@ fn build_liblsl() { let install_dir = cfg.build(); // emit link directives - let libdir = install_dir.join("lib"); let libname = "lsl"; println!( "cargo:rustc-link-search=native={}", - libdir.to_str().unwrap() + install_dir.join("lib").to_str().unwrap() ); + + // on some/most linux builds targeting a 64-bit system, + // the library is placed in PREFIX/lib64 instead of PREFIX/lib + // see: https://stackoverflow.com/questions/76517286/how-does-cmake-decide-to-make-a-lib-or-lib64-directory-for-installations + { + let os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + let width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap(); + + if os.contains("linux") && width == "64" { + println!( + "cargo:rustc-link-search=native={}", + install_dir.join("lib64").to_str().unwrap() + ); + } + } + println!("cargo:rustc-link-lib=static={}", libname); // make sure we also link some additional libs