# Is it possible to statically compile libraries into erts itself?

**URL:** <https://erlangforums.com/t/is-it-possible-to-statically-compile-libraries-into-erts-itself/2649>\
**Category:** Questions / Help\
**Tags:** erts\
**Created:** [May 31, 2023, 7:18am UTC](https://erlangforums.com/t/is-it-possible-to-statically-compile-libraries-into-erts-itself/2649 "2023-05-31T07:18:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dch](https://erlangforums.com/user_avatar/erlangforums.com/dch/32/962_2.png) [@dch](https://erlangforums.com/u/dch)\
**Post date:** [May 31, 2023, 7:18am UTC](https://erlangforums.com/t/is-it-possible-to-statically-compile-libraries-into-erts-itself/2649/1 "2023-05-31T07:18:32Z")

</div>

I have a very vague (R14 timeframe) recollection of it being possible to statically compile libraries into erts itself. Not NIFs, and not requiring an external / dynamic .so.

Back in R14 days, it took over 20 hours to compile OTP, but now its only a few minutes.

This is already broadly possible with SSL & ZLIB I believe, at configure time,via `--disable-dynamic-ssl-lib` and `--enable-builtin-zlib`.

Is this possible today, in some more generic capacity?

I have a few things where shipping a nice phat erts + .ez jammed together would be _really_ nice, and I can afford the up-front compile time impact, for the simplicity of a single binary. Tools like [bakeware](https://github.com/bake-bake-bake/bakeware) and [burrito](https://github.com/burrito-elixir/burrito) are nice, but don’t solve the NIF situation.

---

<div class="post-metadata">

**Author:** ![holger](https://erlangforums.com/user_avatar/erlangforums.com/holger/32/831_2.png) [@holger](https://erlangforums.com/u/holger)\
**Post date:** [May 31, 2023, 11:02am UTC](https://erlangforums.com/t/is-it-possible-to-statically-compile-libraries-into-erts-itself/2649/2 "2023-05-31T11:02:02Z")

</div>

For what it’s worth, I have a [lenghty script](https://github.com/processone/eturnal/blob/master/scripts/make-binaries) for building portable Linux binaries for a project of mine (ejabberd [uses](https://github.com/processone/ejabberd/blob/master/tools/make-binaries) the same idea). The binaries have no external dependencies except for glibc 2.19+ (and the magic could easily be modified to link statically against Musl instead). The OTP `./configure` flag `--enable-static-nifs` is used to avoid NIF `.so`s (mostly to avoid duplicating external library code into multiple `.so`s).

However, this doesn’t end up with a single binary, my goal is just portability by avoiding external dependencies. And as I said, the script is … lengthy.

---

<div class="post-metadata">

**Author:** ![eproxus](https://erlangforums.com/user_avatar/erlangforums.com/eproxus/32/452_2.png) [@eproxus](https://erlangforums.com/u/eproxus)\
**Post date:** [June 1, 2023, 10:47am UTC](https://erlangforums.com/t/is-it-possible-to-statically-compile-libraries-into-erts-itself/2649/3 "2023-06-01T10:47:41Z")

</div>

We do this when cross-compiling the BEAM for GRiSP. See e.g. our cross-compilation configuration [here](https://github.com/grisp/grisp/blob/master/grisp/grisp2/common/build/files/xcomp/erl-xcomp-arm-rtems5.conf).

It is a more involved build process including our [own build tool](https://github.com/grisp/grisp_tools/blob/master/src/grisp_tools_build.erl) and a [custom toolchain](https://github.com/grisp/grisp2-rtems-toolchain).
