On Friday, 15 November 2013 at 15:27:45 UTC, Jacek Furmankiewicz wrote:
One of the nice features of Go is that when you compile an app, it pulls in ALL the dependencies (i.e. the full SDK + all libraries your app depends on) and generates a single binary (around 2 MB for a Hello World app).

This is extremely useful for deployment purposes, since it is so straightforward to just copy the app to multiple servers without having to worry if every one of them has all the required dependencies installed / updated, etc.

Does D offer something similar (maybe via some dmd switches)?

For example, If I am creating a vibe.d app, would I need to deploy the vibe.d libraries separately with my app on all the servers in production?

Thanks
Jacek

Go provides only static linking. D provides both and it is up to developer to decide. Often it is simply a matter of what version of library is installed in the system - static or dynamic one.

You can use `ldd` on Linux to check dynamic dependencies for any given binary. On my Arch Linux installation output for simple vibe.d app looks like this:

$ ldd ./test
        linux-vdso.so.1 (0x00007fba8f53b000)
libevent_pthreads-2.0.so.5 => /usr/lib/libevent_pthreads-2.0.so.5 (0x00007fba8f11b000) libevent-2.0.so.5 => /usr/lib/libevent-2.0.so.5 (0x00007fba8eed3000)
        libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007fba8ec66000)
libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007fba8e85e000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fba8e640000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007fba8e33d000)
        librt.so.1 => /usr/lib/librt.so.1 (0x00007fba8e135000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007fba8dd8a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fba8f31e000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fba8db86000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007fba8d970000)

List may differ between distros / operating systems.

Note that you can't "force" static linking if only shared libraries are present in the system and AFAIK Go does no magic here - it will simply fail to compile/link in such situation.

tl; dr: yes, if you use static versions of required libraries

Reply via email to