Closed calavera closed 4 years ago
:thinking: interesting. So you have a working solution but you're hoping for a better one; correct?
I think it's unexpected that putting both projects in a workspace makes the shared object not valid anymore. This workaround also creates two target directories, which is not ideal.
It looks like the real issue is this: https://github.com/rust-lang/rust/issues/46369. I tested my project using cdynlib
and it creates the object correctly with both projects in the workspace.
I bumped into an interesting issue with Cargo workspaces.
I have a repository with two Rust libraries, one of them is the "core" library where I have a bunch of shared code. The other library is a ruby gem built with Rutie.
When I put both libraries in the workspace, the generated dynamic library includes a reference to
libstd
, which cannot be resolved in my system because I don't have anything set in LD_LIBRARY_PATH. That dynamic library won't work when it's loaded by the Ruby bindings.If I put the "core" inside the workspace, but I exclude the Rutie library, the dynamic library generated doesn't include the reference to
libstd
and it works (as far as I can tell, I still have to add tests to the ruby part).So the workaround to solve this problem is to have the Rutie library in the Cargo workspace like this:
I'm not familiar with the build toolchain, but I'd expect to be a better solution to this problem.