DUB and Gtk-d reduce size of huge executable, build dynamic dependencies
Gerald
gerald.b.nunn at gmail.com
Sat Mar 10 15:46:58 UTC 2018
On Wednesday, 7 March 2018 at 10:51:49 UTC, CSim wrote:
> Hi,
>
> I'm trying to decide whether it is better to use DLang for Gtk
> development or Vala/Genie.
>
> When I make a simple Vala/Genie Gtk executable the file is tiny
> whereas the DLang file is huge. First I used the default Dub
> build and the file was in excess of 60mb (assuming this
> includes debug build). Using dub build=release the file is
> still more than 7 mb. Using a native Vala/Genie build the file
> is less than 500k.
>
> Trying to understand what is going on, but I assume from this
> that Dub is linking static dependencies, whereas the Vala/Genie
> builds will link to dynamic libraries.
>
>
> So my (two pronged) question is this: Is there any way to
> specify in dub.json to build and link dependencies as dynamic
> libraries, and are there any other tips that can be used to
> reduce these (relatively) huge executables?
Personally, I do not worry too much about the executable size,
however a couple of tips as follows:
a. If this is on linux use "strip" to remove symbols out of the
executable
b. In dub.json you can specify just the portions of GtkD that
your application depends on, i.e.:
"dependencies": {
"gtk-d:gtkd": {
"version": "3.7.5"
},
"gtk-d:vte": {
"version": "3.7.5"
}
}
Is what I use in tilix (https://github.com/gnunn1/tilix)
c. You can dynamically link to GtkD, in tilix I have the config
below to do so. Interestingly on ldc it doesn't make any
difference in size though using ldd I can see the dependency to
GtkD. With DMD it is smaller however I cannpt run it since the
Arch Linux GtkD package is compiled with ldc2.
{
"name": "dynamic",
"targetType": "executable",
"libs": ["gtkd-3"],
"libs-linux": ["X11"],
"lflags": ["-defaultlib=libgtkd-3.so"],
"versions": ["StdLoggerDisableTrace"]
}
More information about the Digitalmars-d-learn
mailing list