www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to build static linked executable

reply zunkree <zunkree gmail.com> writes:
Hi,

Is there a way to build static linked executable with dub for 
vibe-d based app?

Regards,
zunkree
Mar 17 2018
parent reply Seb <seb wilzba.ch> writes:
On Saturday, 17 March 2018 at 14:44:42 UTC, zunkree wrote:
 Hi,

 Is there a way to build static linked executable with dub for 
 vibe-d based app?

 Regards,
 zunkree
Yes, use -static Here's how we build the DTour: https://github.com/dlang-tour/core/blob/master/dub.sdl
Mar 17 2018
next sibling parent Seb <seb wilzba.ch> writes:
On Saturday, 17 March 2018 at 15:42:06 UTC, Seb wrote:
 On Saturday, 17 March 2018 at 14:44:42 UTC, zunkree wrote:
 Hi,

 Is there a way to build static linked executable with dub for 
 vibe-d based app?

 Regards,
 zunkree
Yes, use -static Here's how we build the DTour: https://github.com/dlang-tour/core/blob/master/dub.sdl
I forgot to mention that -static is an LDC-only flag, but you wouldn't want to use DMD for an optimized application anyhow.
Mar 17 2018
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2018-03-17 16:42, Seb wrote:

 Yes, use -static
 
 Here's how we build the DTour: 
 https://github.com/dlang-tour/core/blob/master/dub.sdl
FYI, -static is not support on macOS. -- /Jacob Carlborg
Mar 18 2018
parent reply zunkree <zunkree gmail.com> writes:
On Sunday, 18 March 2018 at 14:36:04 UTC, Jacob Carlborg wrote:
 On 2018-03-17 16:42, Seb wrote:

 Yes, use -static
 
 Here's how we build the DTour: 
 https://github.com/dlang-tour/core/blob/master/dub.sdl
FYI, -static is not support on macOS.
So, how to build static binary for macOS?
Mar 20 2018
next sibling parent David Nadlinger <code klickverbot.at> writes:
On Tuesday, 20 March 2018 at 10:37:55 UTC, zunkree wrote:
 On Sunday, 18 March 2018 at 14:36:04 UTC, Jacob Carlborg wrote:
 FYI, -static is not support on macOS.
So, how to build static binary for macOS?
Static binaries aren't really supported by Apple (anymore). What do you need it for? — David
Mar 20 2018
prev sibling parent Jacob Carlborg <doob me.com> writes:
On Tuesday, 20 March 2018 at 10:37:55 UTC, zunkree wrote:

 So, how to build static binary for macOS?
I don't see a need to do that. I build static binaries on Linux because they work across all distros and all versions. But for macOS, there are no distros. For supporting multiple versions, or rather an older version than you're building on, you can use the "-macosx_version_min" linker flag. See [1] for an example. If you really want a static binary, I think it's possible if you're calling the kernel directly (I think Go can do this). But then most of D would not work, since it builds on the C standard library. [1] https://github.com/jacob-carlborg/dstep/blob/19a5ddb8ad3f44b3445c89840155bb7cd1ee44b7/dub.json#L20 -- /Jacob Carlborg
Mar 20 2018
prev sibling parent zunkree <zunkree gmail.com> writes:
On Saturday, 17 March 2018 at 15:42:06 UTC, Seb wrote:
 On Saturday, 17 March 2018 at 14:44:42 UTC, zunkree wrote:
 Hi,

 Is there a way to build static linked executable with dub for 
 vibe-d based app?

 Regards,
 zunkree
Yes, use -static Here's how we build the DTour: https://github.com/dlang-tour/core/blob/master/dub.sdl
Thank you very much.
Mar 20 2018