0

In build.rs of level1-sys crate I have:

    let dst = cmake::Config::new(Path::new("somelib"))
        .build()
        .join("build");
    println!("cargo:rustc-link-search=native={}", dst.display());
    println!("cargo:rustc-link-lib=dylib=somelib");

then there is level2 create that deped on level1-sys, and then there is level3binary crate.

If I run this level3 crates via cargo run all works fine, but if I run it by hands it reports:

 error while loading shared libraries: libsomelib.so: cannot open shared object file: No such file or directory

Is there way to find path to libsomelib.so from cargo? I need this info for external script that should pack binary.

Obviously I can search in target subdirectory, but I use debug/release/cross compilation and so on thing. Plus even for concrete variant like target/release after several rebuild of level1-sys there are several libsomelib.so libraries, like:

target/release/build/level1-sys-46422ddc8585ba79/libsomelib.so
target/release/build/level1-sys-9daa760ee41fe7b8/libsomelib.so
user1244932
  • 7,352
  • 5
  • 46
  • 103
  • https://stackoverflow.com/questions/55537573/how-to-link-a-dynamic-rust-library-using-only-rustc-and-not-cargo#comment97778955_55537573 – Stargateur Apr 05 '19 at 16:29
  • @Stargateur If I do `cargo clean` and `cargo build -v -v` other teammates send me to the hell. Clean build takes ~30 minutes. – user1244932 Apr 05 '19 at 16:34
  • try [`touch build.rs && cargo build -vv`](https://stackoverflow.com/questions/49077147/how-can-i-force-build-rs-to-run-again-without-cleaning-my-whole-project/55536259#55536259), you all works on the same machine ? – Stargateur Apr 05 '19 at 16:36
  • @Stargateur We use this script a lot during development, so everyone become unhappy if build of package start takes 30 mins on their local machine. – user1244932 Apr 05 '19 at 16:54
  • @Stargateur But this cause rebuild of `level2` and `level3` packages, this is of course not 30 minutes, but 2 minutes also not good. Is any way to avoid rebuild just to find out path? – user1244932 Apr 05 '19 at 16:55
  • do that `build.rs` don't rebuild level2 and level3 packages if they are up to date ? I have no idea how. but at some point this is just a trick to see what cargo do... as you said "If I run this level3 crates via cargo run all works fine, but if I run it by hands it reports:" – Stargateur Apr 05 '19 at 16:58

0 Answers0