On Saturday, 17 October 2015 at 13:54:12 UTC, Shriramana Sharma wrote:
Marc Schütz wrote:

Yes, it's still linked statically by default, at least with DMD. I don't know why this wasn't changed yet, I just tried linking against libphobos.so and it worked. The resulting binary is then down to 13 Kb, after stripping.

Wow that's nice to hear! Can you outline the steps to link any given .d file against libphobos.so?

Unfortunately, I haven't found a switch that makes DMD use dynamic linking. Maybe I just missed it... So, you have to do it step by step:

1) Use the `-c` switch to make the compiler output:
   dmd -O -inline -c foo.d
   This generates `foo.o`.

2) Link by calling `gcc`:
   gcc -o foo foo.o -lphobos2
This calls `ld` with the right options and results in a binary `foo`.

3) Optionally, strip the binary to make it smaller:
   strip foo

Reply via email to