4 ms·
Yes, in both directions (using a .so, and building a .so in Rust), but IIRC linking to a .so is a bit hairy -- requiring a build.rs (build script) that passes s
by cfallin 7y ago
Yes, in both directions (using a .so, and building a .so in Rust), but IIRC linking to a .so is a bit hairy -- requiring a build.rs (build script) that passes special options to Cargo. Generating a .so is just a different target type to Cargo (cdylib).
- pornel 7y agoTheoretically you could link to a .so with just `#[link(name="soname", kind="dylib")]` in the code. The hairy part is finding the library on the system, and that's a mess that Rust merely inherited. The build scripts are there to run pkg-config, search system lib dirs, and compile a fallback if necessary (next everyone suggests to just have Cargo automatically figure it out, until they see how deep the rabbit hole goes for snowflake libraries like openssl and llvm).
- bscphil 7y agoI guess the critical question is whether it's built up to the point that anyone wants to use it yet. It's one thing to have theoretical support for dynamic linking, but if in practice everyone just ships giant static binaries (which seems to be the emerging default for Go, node, etc), it doesn't help you much.