You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to compile my rust / c++ project into a single .so file that can be dynamically loaded by another application (implementation of a c++ headerfile that uses some rust calls, linked from a c++ app). This seems to generally work when using a static library with only needing to link the top-level library:
-Ltarget/debug -lmylib
(assuming target/debug/libmylib.a)
however when attempting to do the same for a cdylib I need to also link the library created during the build script as such:
If I do not explicitly include the static library built as part of build.rs (cxx_build::[..].compile("built-by-cxxbuiild")) I have missing symbols.
Any advice on how to bridge this gap, so that all symbols are exported in the .so. I have attempted to add some linking flags to my build script, such as println!("cargo::rustc-link-lib=static={..}) to no avail.
If it makes a difference, the code exclusively calls from c++ to rust, and not the other way. This is being used as a C++ "shim" to provide a rust implementation of a c++ interface for a shared library.
Thanks!
The text was updated successfully, but these errors were encountered:
I was tinkering with this myself today. My workaround solution at the moment is to build the rust code as a static library. Here's my setup (crate name is sqlite_adaptor).
// Cargo.toml
[lib]
crate-type = ["staticlib"]
This produces target/debug/sqlite_adaptor.a
The next step is to link this static library with the cxxbridge static library built by your build.rs into a shared library:
This is pretty janky right now as I'm still hacking on it, but it produces a shared library with the symbols from Rust library and the needed bridge code in target/debug/libsqlite_adaptor.so
Hi,
I am attempting to compile my rust / c++ project into a single .so file that can be dynamically loaded by another application (implementation of a c++ headerfile that uses some rust calls, linked from a c++ app). This seems to generally work when using a static library with only needing to link the top-level library:
(assuming
target/debug/libmylib.a
)however when attempting to do the same for a cdylib I need to also link the library created during the build script as such:
(assuming
targ/debug/libmylib.so
)If I do not explicitly include the static library built as part of
build.rs
(cxx_build::[..].compile("built-by-cxxbuiild")
) I have missing symbols.Any advice on how to bridge this gap, so that all symbols are exported in the .so. I have attempted to add some linking flags to my build script, such as
println!("cargo::rustc-link-lib=static={..})
to no avail.If it makes a difference, the code exclusively calls from c++ to rust, and not the other way. This is being used as a C++ "shim" to provide a rust implementation of a c++ interface for a shared library.
Thanks!
The text was updated successfully, but these errors were encountered: