swiftubuntuvapor

How to install swift core libraries in production ubuntu server?


I've two ubuntu server 22.04.4 machines. One is in local for development and another one is in server for deployment.

I tested the release build in the local and transfer the executable from local folder .build/release/App to server App. In the local server App is running from any folder not only .build/release/App

When I use command ./Server ServerApp --env production then there is an error message,

./Server: error while loading shared libraries: libswiftCore.so: cannot open shared object file: No such file or directory

I really thought that swift build --configuration release will build standalone binary executable.

In this modern era I really didn't expected the final executable needs runtime libraries instead of using standard operating system API's.

But seems I need run time libraries and I searched lot can't able to find instructions to setup production server. Literally I am new to this. How can I setup and resolve that error?


Solution

  • You're missing the static linking flag during the build:

    swift build -c release --static-swift-stdlib
    

    That will produce a binary you can copy around as long as the underlying OS and architecture is the same