I can use nif's if I write the escript myself, however when I use rebar escriptize the nif functions cannot be found. I think it is because *.so objects are not getting packed like beam files. Here is an simple example;
rebar.config
:
{deps, [
{'jiffy', "", {git, "https://github.com/davisp/jiffy.git", {branch, master}}}
]}.
{escript_incl_apps, [jiffy]}.
%% I tried this to see what happens if the so got in there but didn't help
{escript_incl_extra, [{"deps/jiffy/priv/jiffy.so", "/path/to/my/proj"}]}.
test.erl
:
-module(test).
-export([main/1]).
main(_Args) ->
jiffy:decode(<<"1">>),
ok.
rebar get-deps compile escriptize
./test
and the result is
escript: exception error: undefined function jiffy:decode/1
in function test:main/1 (src/test.erl, line 7)
in call from escript:run/2 (escript.erl, line 741)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_it/1
in call from init:start_em/1
Is there a way to overcome this ?
jiffy.beam
which cannot be found, not*.so
. Maybeescriptize
takes into account only beams fromebin
ignoring dependencies'ebin
s? – Biographicaljiffy:decode/1
withjiffy.so
removed frompriv
you should getFailed to load NIF library
error, notundefined function
– Biographical