On Friday, 8 December 2017 at 06:37:36 UTC, Adam D. Ruppe wrote:
On Friday, 8 December 2017 at 05:16:22 UTC, Fra Mecca wrote:
Is there a way to compile a project and deploying it as a single statically linked binary?

A default build of a D program is *reasonably* compatible. All its dependencies are core operating system components like libc. Now, there can certainly be libc version incompatibilities, but there's a decent chance it will just work.

I'm pretty sure this is the exact same situation Go is in; the default Go and D builds link the same way.


I was curious so I just tried. Building a hello world with "go build" (I just litterally did what was on https://gobyexample.com/hello-world) produces a file that is not a dynamic executable. There is no dependency.

For comparison building a similar hello world with dmd and no options gives the followig dependencies (thanks ldd):

        linux-vdso.so.1 (0x00007fffd02aa000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f45e5e69000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007f45e5b1d000)
        librt.so.1 => /usr/lib/librt.so.1 (0x00007f45e5915000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f45e5711000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f45e54fa000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f45e5142000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f45e6087000)

(And using -L-static produces an error because of an incompatibility with -pie... I'm sure it's workable I just didn't take the time to look it up yet)

Reply via email to