[Solved] See @al45tair message below, thanks again:
Original Problem:
Playing around with cross-compiling with the static linux sdk with a unique situation:
Package contains a system library sourced via pkgconfig
This is already dark territory but here. I have a "app" that utilizes a Swift library (FDB) that is a wrapper around a C library "CFDB" under the name libfdb_c.
import PackageDescription
let package = Package(
name: "qipg",
platforms: [
.macOS(.v13)
],
products: [
.executable(
name: "app",
targets: ["app"]),
.library(
name: "FDBSwift",
targets: ["FDB"]
),
],
dependencies: [
...
],
targets: [
.executableTarget(
name: "app",
dependencies: [
....
"FDB",
]
),
...
.systemLibrary(name: "CFDB", pkgConfig: "libfdb"),
.target(
name: "FDB",
dependencies: [
"CFDB",
...
]
),
]
)
Pkgconfig:
This wrapper is all working and there is a pkgconfig defined for it that is the same for macOS/Linux.
prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: fdb
Description: FoundationDB library
Version: 6.3.23
Cflags: -I${includedir}
Libs: -L${libdir} -lfdb_c
Building Issues
When I kick off a build for macOS in your standard semantics to problems:
swift build
Obviously, for the linux build it would fail because the one install on macOS is not for it.
> swift build --swift-sdk x86_64-swift-linux-musl
[1/1] Planning build
Building for debugging...
error: link command failed with exit code 1 (use -v to see invocation)
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
ld.lld: error: unable to find library -lfdb_c
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[2/3] Linking app
However, is it as simple as placing the linux libfdb_c.so into a folder and passing -L<path to folder>
? It appears not.
swift build --swift-sdk x86_64-swift-linux-musl -Xlinker -L<path to>/lib/
[1/1] Planning build
Building for debugging...
error: link command failed with exit code 1 (use -v to see invocation)
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
ld.lld: error: unable to find library -lfdb_c
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I did reference this:
Which seems to suggest its 'possible'.
Why wouldn't that work here if I have a properly cross-compiled .so? Is there some voodoo I am missing?