www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Single exe vibe.d app

reply Satoshi <satoshi rikarin.org> writes:
Hi,
How can I build single exe application with vibe.d (windows)?
now it require zlib.dll, libeay32.dll and ssleay32.dll

But I need it as single app.
Apr 05
next sibling parent evilrat <evilrat666 gmail.com> writes:
On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:
 Hi,
 How can I build single exe application with vibe.d (windows)?
 now it require zlib.dll, libeay32.dll and ssleay32.dll

 But I need it as single app.
you have to build those as static libraries first, compile vibe.d with that static libs provided to linker(you are most likely will be forced to x64 or m32mscoff depending on compilers used) and that *should* be enough. but there may arise some non obviuos issues such as licensing(some licenses prohibits even linking with some other licenced code) or linking issues, or full disability to do so if dynamic loading is used, or whatever i forgot to remember. sorry if it lacks details. thats just whole process in common.
Apr 05
prev sibling next sibling parent reply evilrat <evilrat666 gmail.com> writes:
On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:
 Hi,
 How can I build single exe application with vibe.d (windows)?
 now it require zlib.dll, libeay32.dll and ssleay32.dll

 But I need it as single app.
btw, if all you need is to ship it as a single file and don't care if it writes anything, you can probably compile-in those .dll's to your .exe as string with D import statement and write them on disk from static module ctor (static shared this{} at module scope) when it launched.
Apr 05
next sibling parent Inquie <Inquie data.com> writes:
On Wednesday, 5 April 2017 at 12:42:23 UTC, evilrat wrote:
 On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:
 Hi,
 How can I build single exe application with vibe.d (windows)?
 now it require zlib.dll, libeay32.dll and ssleay32.dll

 But I need it as single app.
btw, if all you need is to ship it as a single file and don't care if it writes anything, you can probably compile-in those .dll's to your .exe as string with D import statement and write them on disk from static module ctor (static shared this{} at module scope) when it launched.
Why is the writing to disk necessary? Seems like a costly step for no real benefit. The dll gets read in to memory anyways. https://github.com/fancycode/MemoryModule
Apr 05
prev sibling parent Satoshi <satoshi rikarin.org> writes:
On Wednesday, 5 April 2017 at 12:42:23 UTC, evilrat wrote:
 On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:
 Hi,
 How can I build single exe application with vibe.d (windows)?
 now it require zlib.dll, libeay32.dll and ssleay32.dll

 But I need it as single app.
btw, if all you need is to ship it as a single file and don't care if it writes anything, you can probably compile-in those .dll's to your .exe as string with D import statement and write them on disk from static module ctor (static shared this{} at module scope) when it launched.
It's not possible because exe will not run when dll is missing. Phobos (or vibe.d ?) doesn't load dll dynamically by dlopen but link with .lib of the .dll
Apr 06
prev sibling next sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:
 Hi,
 How can I build single exe application with vibe.d (windows)?
 now it require zlib.dll, libeay32.dll and ssleay32.dll

 But I need it as single app.
As Evilrat notes static libraries are one solution, the catch being you need to get them as static libraries. zlib you should easily be able to get as a static lib (making sure you use a compatible linker/ linker format. If for the other libraries that is not possible one approach is described on the d idioms list: http://p0nce.github.io/d-idioms/#Embed-a-dynamic-library-in-an-executable The static library solution is probably the superior choice if available.
Apr 05
prev sibling parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:
 Hi,
 How can I build single exe application with vibe.d (windows)?
 now it require zlib.dll, libeay32.dll and ssleay32.dll

 But I need it as single app.
One solution would be to compile vibe.d without ssl support that way it will not need libeay32 and ssleay32 It should not need zlib, really as zlib is already linked into phobos.
Apr 06
parent reply Suliman <evermind live.ru> writes:
On Thursday, 6 April 2017 at 17:39:15 UTC, Stefan Koch wrote:
 On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:
 Hi,
 How can I build single exe application with vibe.d (windows)?
 now it require zlib.dll, libeay32.dll and ssleay32.dll

 But I need it as single app.
One solution would be to compile vibe.d without ssl support that way it will not need libeay32 and ssleay32 It should not need zlib, really as zlib is already linked into phobos.
Could anybody give very easy explanation about what different between static and dynamic libs. I read a lot of information that dynamic lib allow to loading at runtime and bla-bla-bla, but still do not understand what different between compilation at dynamic and static lib. For example: 1. Does every lib can be compiler as static and as dynamic? 2. Can already compiled lib be converted to from static to dynamic and vise-versa. 3. If I have any dynamic lib, the only way is distribute it with app (or use import) or there is way to embed code from it to app? Personaly I like if I can get single bin without any external dependence. In a lot of cases size do not important, it's better to have single bin, than heap of libs.
Apr 06
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
I'm going to give you a very bad but still a good place to begin with 
explanation.

So, what is an executable? Well in modern operating systems that is a 
file with a very complex structure inside, like PE-COFF or ELF. It has a 
bunch of things as part of this, a dynamic relocation table, sections 
and symbols.

Now, there is a very important symbol it provides a "main" function. 
Normally the libc takes ownership of this and then on calls to the 
c-main that we all know and love (druntime uses this and then passes it 
to another symbol called _Dmain).

What is the difference between a shared library and an executable? Well 
not much, no main function for starters (although Win32 based ones do 
have something like it in its place) and a couple of attributes stored 
in the file.

Executables like shared libraries are final binaries, they cannot be 
further linked with, at least with the most common formats + linkers anyway.

You asked about the difference between a static library and a shared 
library, it isn't quite the right comparison. You should be asking about 
static libraries versus object files. In essence a static library is 
just a group of object files. Not too complicated.
Apr 07
parent reply Suliman <evermind live.ru> writes:
On Friday, 7 April 2017 at 07:15:44 UTC, rikki cattermole wrote:
 I'm going to give you a very bad but still a good place to 
 begin with explanation.

 So, what is an executable? Well in modern operating systems 
 that is a file with a very complex structure inside, like 
 PE-COFF or ELF. It has a bunch of things as part of this, a 
 dynamic relocation table, sections and symbols.

 Now, there is a very important symbol it provides a "main" 
 function. Normally the libc takes ownership of this and then on 
 calls to the c-main that we all know and love (druntime uses 
 this and then passes it to another symbol called _Dmain).

 What is the difference between a shared library and an 
 executable? Well not much, no main function for starters 
 (although Win32 based ones do have something like it in its 
 place) and a couple of attributes stored in the file.

 Executables like shared libraries are final binaries, they 
 cannot be further linked with, at least with the most common 
 formats + linkers anyway.

 You asked about the difference between a static library and a 
 shared library, it isn't quite the right comparison. You should 
 be asking about static libraries versus object files. In 
 essence a static library is just a group of object files. Not 
 too complicated.
Ok, but what about Go? I have heard that it's compile all code to single exe? What is the way it's done there?
Apr 11
parent rikki cattermole <rikki cattermole.co.nz> writes:
On 11/04/2017 8:08 AM, Suliman wrote:
 On Friday, 7 April 2017 at 07:15:44 UTC, rikki cattermole wrote:
 I'm going to give you a very bad but still a good place to begin with
 explanation.

 So, what is an executable? Well in modern operating systems that is a
 file with a very complex structure inside, like PE-COFF or ELF. It has
 a bunch of things as part of this, a dynamic relocation table,
 sections and symbols.

 Now, there is a very important symbol it provides a "main" function.
 Normally the libc takes ownership of this and then on calls to the
 c-main that we all know and love (druntime uses this and then passes
 it to another symbol called _Dmain).

 What is the difference between a shared library and an executable?
 Well not much, no main function for starters (although Win32 based
 ones do have something like it in its place) and a couple of
 attributes stored in the file.

 Executables like shared libraries are final binaries, they cannot be
 further linked with, at least with the most common formats + linkers
 anyway.

 You asked about the difference between a static library and a shared
 library, it isn't quite the right comparison. You should be asking
 about static libraries versus object files. In essence a static
 library is just a group of object files. Not too complicated.
Ok, but what about Go? I have heard that it's compile all code to single exe? What is the way it's done there?
I can't quote what Go has for a runtime (and if it does the _Dmain trick) but over all, since it is a native language everything I have said should be valid. I just checked[0] it is all completely valid, Go forces you to jump through hoops to do it though. [0] http://blog.hashbangbash.com/2014/04/linking-golang-statically/
Apr 11