a static library is not linked properly to a required system library · Issue #110143 · rust-lang/rust (original) (raw)
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:
Undefined symbols for architecture x86_64:
"_SCDynamicStoreCopyComputerName", referenced from:
whoami::platform::devicename_os::hfd1ed897939614da in libaries_askar.a(whoami-3e3bd00337b8ac7e.whoami.50980d84-cgu.12.rcgu.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I could resolve this link error by importing SystemConfiguration framework in a swift file of my app.
#if os(macOS) import SystemConfiguration #endif
Steps
- Create a crate that depends on the "whoami" crate.
- Build the crate as a static library.
- Create an xcframework of the library.
- Create a Swift package and add the xcframework as a binary target dependency.
- Build the package.
Possible Solution(s)
No response
Notes
- I only tested this on macOS, not on iOS.
- I'm not sure if this is a bug or not.
Version
cargo 1.67.1 (8ecd4f20a 2023-01-10)
release: 1.67.1
commit-hash: 8ecd4f20a9efb626975ac18a016d480dc7183d9b
commit-date: 2023-01-10
host: x86_64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.2.1 [64-bit]