Hello,
I have a project with hummingbird as a dependency that I would like to build into a statically linked excecutable.
When I build a release with the "-static-stdlib" flag I get this error:
Building for production...
error: link command failed with exit code 1 (use -v to see invocation)
/usr/bin/ld.gold: error: cannot find -lDispatchStubs
/usr/bin/ld.gold: error: cannot find -lCoreFoundation
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
error: fatalError
I use Ubuntu (WSL2). I assume that I'm missing some dependency.
But which one and how can I install it?
So far I'm unable to resolve this problem using google.
These should be automatically supplied by the toolchain, so something is going wrong. You'll need to provide the full build command you are running and the full error output from running in verbose mode by passing -v to SwiftPM.
Edit: The Definition of the Package.swift might not be optimal, or contain errors as I don't yet really understand the package manager.
However, I get the same error when I add the "-static-stdlib" Flag to the Package.swift definition of the official humminbirg example: https://github.com/hummingbird-project/hummingbird-examples/tree/main/hello
OK, I'm able to reproduce with your linked hello example. The problem appears to be that -static-stdlib is both a compilation and linker flag, which SwiftPM separates out for maximum configurability. You have two choices to build and link against the static stdlib:
If you only want that single SwiftPM executable target to be linked against the static stdlib, also add a linkerSettings: [.unsafeFlags(["-static-stdlib"])] right after the swiftSettings you added.