Small program producing binary with large filesize
Jacob Shtokolov
jacob.100205 at gmail.com
Sun Nov 10 12:05:34 UTC 2019
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
More information about the Digitalmars-d-learn
mailing list