How do I statically build a project using DUB?
James Blachly
james.blachly at gmail.com
Sat Aug 29 14:35:31 UTC 2020
On Saturday, 29 August 2020 at 11:27:28 UTC, Kirill wrote:
> I need a stand-alone executable that does not require the user
> to install any libraries on their computer. Everything should
> be packed into the executable.
>
> I understand that I need to statically link all of the
> libraries I use in my project, but how do I do this? What do I
> need to add to dub.json file? What compiler flags do I need to
> use?
>
> Thanks in advance.
It may be extremely difficult if you intend to also link libc;
the gethostbyname DNS functions in glibc do not support static
linking.
OTOH you can create a fairly portably binary by static linking
everything EXCEPT libc (I.e., do not pass -static flag to linker)
— here you would need to link to the .a files of all your
projects library deps as well as your dependencies dependencies...
More information about the Digitalmars-d-learn
mailing list