[erlang-questions] Making a minimal distributable program in Erlang.

Joe Armstrong <>
Thu Sep 21 22:08:03 CEST 2017


On Thu, Sep 21, 2017 at 1:22 PM, Jesper Louis Andersen
<> wrote:
> I think one of the reasons for the directory structure has to do with
> hot-code-upgrades. It is way easier if your system is able to load stuff
> individually from files rather than having to work with static binaries.
>
> Static binaries would be nice. But a full implementation must also be able
> to load patches into the binary later on, if you decide to upgrade the
> running code. This may not be that simple to pull off, though ELF can do
> tricks.
>
>
> On Thu, Sep 21, 2017 at 1:15 PM Frank Muller <>
> wrote:
>>
>> Stefan,
>>
>> By statically linking bins, Joe is talking about the executables here
>> (erl.exe, ...), not the beam files IMHO.
>>
>> You'll be able to reload your beam modules on the fly, obviously.
>>
>> Moreover, nothing prevent a statically built executable to load a shared
>> lib while running.

Problem is that I want to distribute only one file.

As it is now we have to  distribute a shell script erlexec and a DLL that
gets (somehow) loaded when erlexec is run.

Is there some way to statically link the code that erlexec causes to be
dynamically loaded?

/Joe



>>
>> @Joe: just made a quick search and found UPX binary packer. It's
>> cross-platform:
>> https://upx.github.io/
>>
>> Can you please try to shrink the minimal VM binaries on Windows and report
>> back the new size?
>> Use: upx.exe -9 ...
>>
>> /Frank
>>
>>
>>>
>>> >
>>> > So my first question is - how can I compile Erlang into a single file
>>> > executable? - I want no scripts/batch files to launch erlang no DLLs
>>> > and a statically linked binary?
>>>
>>> Getting rid of scripts/batch files you can do if you generalize the
>>> erlexec binary a bit (in Docker for instance, as it was mentioned before,
>>> you perhaps want to be able to configure more things with environment
>>> variables for instance) but what would "statically linked" mean in the world
>>> of modules that load shared objects and even modules that can be upgraded?
>>> To statically link one would have to sacrifice the dynamic code reload,
>>> right?
>>>
>>> /Stefan
>>>
>>> >
>>> > /Joe
>>> >
>>> >
>>> >
>>> > On Wed, Sep 20, 2017 at 4:34 PM, Frank Muller
>>> > <> wrote:
>>> >> Do you think it's possible to package this minimal distribution in one
>>> >> excutable?
>>> >>
>>> >> Imagine we can ship a whole release in one binary (like in Go).
>>> >>
>>> >> /Frank
>>> >>
>>> >> Wed 20 sept. 2017 at 16:23, Joe Armstrong <> wrote :
>>> >>>
>>> >>> Thanks everybody for you help - I got it down to 5.5MB in 9 files
>>> >>> Relocated as follows. I've also packed/compressed the libraries
>>> >>>
>>> >>> Here are the files that are needed
>>> >>>
>>> >>> %% DEST/bin/erl.exe                     120320 bytes
>>> >>> %% DEST/bin/start.boot                    5603 bytes
>>> >>> %% DEST/erts-9.0/bin/beam.smp.dll      3346944 bytes
>>> >>> %% DEST/erts-9.0/bin/erlexec.dll        162304 bytes
>>> >>> %% DEST/erts-9.0/bin/inet_gethost.exec   45568 bytes
>>> >>> %% DEST/lib/compiler-7.1.ez             409091 bytes
>>> >>> %% DEST/lib/kernel-5.2.ez               384730 bytes
>>> >>> %% DEST/lib/sasl-3.0.4.ez               106278 bytes
>>> >>> %% DEST/lib/stdlib-3.4.ez               913013 bytes
>>> >>>
>>> >>> This seems to work :-)
>>> >>>
>>> >>> Cheers
>>> >>>
>>> >>> /Joe
>>> >>>
>>> >>> On Wed, Sep 20, 2017 at 2:24 PM, Dmitry Kolesnikov
>>> >>> <> wrote:
>>> >>>> Hello,
>>> >>>>
>>> >>>> On 20 Sep 2017, at 13.35, Stu Bailey <> wrote:
>>> >>>>
>>> >>>> "As an afterthought - it would be *very nice* to have a program
>>> >>>> which
>>> >>>> makes a minimal distributable program for Windows/Mac/Linux."
>>> >>>>
>>> >>>>
>>> >>>> This program is called relx.
>>> >>>>
>>> >>>> It generates a release package which are deployable to any vanilla
>>> >>>> linux
>>> >>>> or
>>> >>>> other vanilla os.
>>> >>>> The usage of Docker-image-with-Erlang complicates the process of
>>> >>>> distribution.
>>> >>>>
>>> >>>> Best Regards,
>>> >>>> Dmitry
>>> >>>>
>>> >>>>
>>> >>> _______________________________________________
>>> >>> erlang-questions mailing list
>>> >>> 
>>> >>> http://erlang.org/mailman/listinfo/erlang-questions
>>> > _______________________________________________
>>> > erlang-questions mailing list
>>> > 
>>> > http://erlang.org/mailman/listinfo/erlang-questions
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions


More information about the erlang-questions mailing list