From 5a35cb726271e78d72f5f9b5ee2163822bd30767 Mon Sep 17 00:00:00 2001 From: unrealhoang Date: Wed, 29 Jul 2020 16:02:31 +0900 Subject: [PATCH] Add link stdlib when linking prebuilt rocksdb (#443) --- librocksdb-sys/build.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 0a0fb54..4064748 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -333,6 +333,14 @@ fn main() { println!("cargo:rerun-if-changed=rocksdb/"); fail_on_empty_directory("rocksdb"); build_rocksdb(); + } else { + let target = env::var("TARGET").unwrap(); + // according to https://github.com/alexcrichton/cc-rs/blob/master/src/lib.rs#L2189 + if target.contains("apple") || target.contains("freebsd") || target.contains("openbsd") { + println!("cargo:rustc-link-lib=dylib=c++"); + } else if target.contains("linux") { + println!("cargo:rustc-link-lib=dylib=stdc++"); + } } if cfg!(feature = "snappy") && !try_to_find_and_link_lib("SNAPPY") { println!("cargo:rerun-if-changed=snappy/");