Thread overview
How to build static linked executable
Mar 17, 2018
zunkree
Mar 17, 2018
Seb
Mar 17, 2018
Seb
Mar 18, 2018
Jacob Carlborg
Mar 20, 2018
zunkree
Mar 20, 2018
David Nadlinger
Mar 20, 2018
Jacob Carlborg
Mar 20, 2018
zunkree
March 17, 2018
Hi,

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

Regards,
zunkree
March 17, 2018
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
March 17, 2018
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.
March 18, 2018
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
March 20, 2018
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.
March 20, 2018
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?
March 20, 2018
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
March 20, 2018
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