Regarding Foundation dependency on non-Apple platforms

I am wondering about one thing:

Suppose that I compiled a library or an executive with no dependencies at all (no Foundation).

If I want it to run on a freshly-installed Windows or Linux, should I deploy Foundation first? Or it is capable for just-run in such situation?

You don’t need Foundation in this case, but SwiftCore and other standard libraries are still required (unless you enable static standard library mode on Linux). On Windows it’s recommended to use MSM for integrating Swift libraries into the package installer of your product (or just copy the required DLLs alongside).

1 Like

Thanks. So the thing I need for both platforms is to add --static-swift-stdlib right after swift build -c release ?

I have no problem shipping the required DLLs together with the target on Windows.

--static-swift-stdlib is only available on Linux for the time, and with this flag on all standard libraries will be included in the executable binary. On Windows you just compile with regular setup, and copy the DLLs around.

1 Like

Important to note: not all standard libraries are linked statically. Both libstdc++ and Glibc are linked dynamically, and specifically Glibc can't be linked statically at all. When deploying to an arbitrary Linux distribution you need to make sure that correct versions of these libraries are present.

2 Likes