Open conanoc opened 1 year ago
Transferred to rust-lang/rust, as cargo is not involved in linking.
@rustbot label +A-linkage
The whoami
crate correctly added a dependency on the SystemConfiguration
framework: https://github.com/ardaku/whoami/blob/1c076a5ac667c0258f9649efd346b238ab9c7b87/src/unix.rs#L82
The issue is that if you are building a staticlib, there is no way for the staticlib itself to define all dynamic libraries it depends on. As such you need to pass --print native-static-libs
to rustc when compiling the staticlib and then use all the linker arguments it prints when linking against the staticlib. For example it could show:
note: Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
note: native-static-libs: -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc
in which case you have to pass -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc
to the linker when linking against the staticlib.
Problem
I created a crate as a static library named
libaries_askar.a
. When I create an Xcode project that uses this library, build fails with the following error:I could resolve this link error by importing SystemConfiguration framework in a swift file of my app.
Steps
Possible Solution(s)
No response
Notes
Version