Deploying crate built native shared libraries (.so/.dll)

What is the best/recommended way to either have a crate being built to output it's generated native shared libraries to a different location for packaging/deployment or be able to copy it from the correct path, There seems to be no way to know what that path should be as there could potentially be multiple versions built and each version has UUID in the directory name. The only way seems to be to copy the file from the crate's build script.

The other way would be to make a script that builds to different target location and search for those dependencies in the build directory.

There is an unstable cargo flag for this purpose in development https://github.com/rust-lang/cargo/issues/6790.

But, the output artifacts do not have unique IDs in their file paths as is; binaries and cdylibs alike will always be built to /target/{profile}/{name} or /target/{triple}/{profile}/{name}.

e.g. on Linux, if you are developing a library "foo", you will find it at either /target/release/libfoo.so or /target/x86_64-unknown-linux-gnu/release/libfoo.so

1 Like

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.