Cannot link dylib
crate to staticlib
crate
#118162
Labels
A-docs
Area: documentation for any part of the project, including the compiler, standard library, and tools
A-linkage
Area: linking into static, shared libraries and binaries
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Problem
If you have a
dylib
-kind crate and try to use it from astaticlib
-kind crate, you get this error:Steps
cargo build
Possible Solution(s)
Ideally metadata in the
.lib
would be generated to make the eventual target link to the shared library, I assume through thenative-static-libs
. It would be fine without this though, I'm fine with manually linking it.Alternatively, if this is not a valid configuration, a better error message would be appreciated
Notes
My usecase is something I think should be supported--I'm writing a static library to be consumed from a C++ application, and it needs a tokio runtime that will be shared with other static libraries. So I've put the tokio runtime in the dynamic library.
My workaround for now is to make it a
cdylib
and not to mangle the function, and import it with anextern
section.Maybe there's a better way to do what I'm trying to do?
Version
The text was updated successfully, but these errors were encountered: