On Monday, 21 October 2019 at 19:20:04 UTC, Prokop Hapala wrote:
What exactly should I specify to make it link dynamcially and produce as small binary as possible (without increasing compilation time) ?

Hi! Sorry, just found your response here. In order to force it to link dynamically, add these lines to your `dub.json`:

```
"buildTypes": {
    "release-shared": {
        "dflags": ["-link-defaultlib-shared", "-release", "-O3"]
    }
},
"postBuildCommands": [
    "strip ./<my_app>"
]
```

Then build it like that:

```
dub build --build=release-shared --compiler=ldc2
```

Make sure that you replace <my_app> under `postBuildCommands` with your own application (binary) name.

The thing is that LDC2 links statically by default, so you have to add a few flags to the command line

Reply via email to