Is it possible to build a swift project on Linux using the
-Xswiftc -static-stdlib flags?
What I want to archive, is to create command line tool which can be executed on other Linux machines without the need to install the swift. As far as I understand the
-Xswiftc -static-stdlib flag should allow this but adding this flag produce errors during the
Compile Swift Module 'ExampleProject' (1 sources) Linking ./.build/x86_64-unknown-linux/release/ExampleProject /usr/bin/ld.gold: error: cannot find -ldispatch clang: error: linker command failed with exit code 1 (use -v to see invocation) <unknown>:0: error: link command failed with exit code 1 (use -v to see invocation) error: terminated(1): /home/mateusz/Developer/swift/4.2.1/usr/bin/swift-build-tool -f /home/mateusz/Developer/ExampleProject/.build/release.yaml main output:
Steps to reproduce (I assume that the Swift has been already installed):
- Init new project: swift package init --type executable
import Frameworkto the created
swift build -c release -Xswiftc -static-stdlib
Swift version 4.2.1 (swift-4.2.1-RELEASE) Target: x86_64-unknown-linux-gnu
Here you can found output from the
swift build -c release -Xswiftc -static-stdlib -Xlinker --verbose command
I have read the Building distributable executable using SwiftPM but I'm not sure if it describes the same problem :(.