How to prepare and generate a simple lightweight binary?

kinke kinke at gmx.net
Tue Jun 25 13:51:15 UTC 2019


On Tuesday, 25 June 2019 at 13:13:34 UTC, BoQsc wrote:
> What I would expect: A simple executable program that does a 
> writeln and do not weight tons of megabytes. Thanks.

void main()
{
     import std.stdio;
     writeln("Hello world!");
}

Ubuntu 18.04, LDC v1.16:

> ldc2 hello.d
=> ~1.7 MB

> ldc2 hello.d -link-defaultlib-shared
=> < 20 KB

The 2nd executable depends on the shared druntime and Phobos 
libraries though, whereas the first one is standalone.


More information about the Digitalmars-d-learn mailing list