Hi, i have created a simple lib using cxx that used a external c++ lib as a dependency, i was able to compile and link this lib using cmake-rs, but for some reason when i tried to use the lib i get a error from the compiler saying it was unable to find the c++ lib a have used as a dependency.
The build.rs file of the lib:
use cmake::Config;
fn main() {
cxx_build::bridge("src/lib.rs")
.file("cpp/main.cpp")
.flag_if_supported("-std=c++17")
.compile("cxx-bridge");
let dst = Config::new("cpp")
.cxxflag("-std=c++17")
.env("REALM_CPP_NO_TESTS", "ON")
.env("CMAKE_CXX_FLAGS", "-fpermissive -Wchanges-meaning")
.build();
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=cpprealm");
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed=cpp/main.cpp");
println!("cargo:rerun-if-changed=cpp/main.h");
}
When runing cargo build on the lib itself it compiles without any problem, but when i try to run it as a dependency of another project i receive the error:
= note: /usr/bin/ld: cannot find -lcpprealm: No such file or directory
collect2: error: ld returned 1 exit status
I don't have many experience using cpp code with rust so any help is much appreciated.