Packaging/installing C/C++ shared libraries built as part of the Cargo build process

I have projects that wrap C/C++ libraries and so (optionally) build those libraries and their dependencies along with the Rust bin/lib using the cmake crate from the build.rs.

If everything is static this mostly just works, but occasionally those C++ libraries have to be built shared (e.g. Intel TBB). Now the Rust binary is pointing to a shared library somewhere in the local target/release/blah directory structure.

The ideal would probably be to install the libraries in question along with the Rust binary with cargo install or some other instal method, but there doesn’t seem to be any way to tell Cargo about these libraries.

The only way I’ve thought to accomplish this is to modify build.rs to copy the libraries somewhere “sensible” after they’re built, like directly up to target/ and then use another script such as a Makefile to handle installation/packaging (and patching rpath) from there.

Has anybody else dealt with this and come up with a solution they like?

1 Like

Possibly relevant issue (?)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.