[erlang-questions] Looking for details on static linking of NIFs

Neeraj Sharma neerajsharma.live@REDACTED
Tue Jun 14 19:56:17 CEST 2016

On Sun, Jun 12, 2016 at 10:42 PM, Neeraj Sharma
<neerajsharma.live@REDACTED> wrote:
> Hi,
> I want to use crypto (and other NIFs) without letting Erlang
> dynamically load them when started. After going through a number of
> documents and particularly the following two I still cannot figure out
> why Erlang tries to load the crypto library when trying to start the
> crypto or via crypto:start().
> http://erlang.org/doc/man/erl_nif.html
> http://erlang.org/doc/installation_guide/INSTALL.html
> I am building Erlang with --enable-static-nifs and
> --disable-dynamic-ssl-lib. Any clue or pointers to internal operations
> of the static NIFs will be of great help.

I finally got my build working and ran a quick test to see the
successful outcome. I started direct conversation with Lukas (github:
garazdawi) and got some pointers from him as well. In the end I found
a build issue with Erlang 18.3 and 19.0-rc2 for my use case, where I
am cross compiling and additionally providing static libraries for
openssl as well. It appears that this use case is probably not tested
and hence source of failure and confusion on my part.
Eventually I found that using "--enable-static-nifs" enables static
compilation for both crypto and asn1 by default so providing absolute
paths to archives to both the NIFs is unnecessary (though that will
work too). Additionally, there is trickiness to using a custom built
openssl where certain ciphering alogs are required by the latest
Erlang 19.0-rc2 and hence must be available. Also, as giving in the
installation docs LIBS="${OPENSSL_PATH}/lib/libcrypto.a" is also
required before running configure so that the crypto NIF gets built
correctly. There is a build issue for both Erlang 18.3 and 19.0-rc2
(and probably others) in the above scenario, which I will be posting
(as a patch) on github/erlang/otp tonight or tomorrow.


More information about the erlang-questions mailing list