如果我自己编写escript,我可以使用nif,但是当我使用rebar escriptize时,无法找到nif函数.我认为这是因为*.so对象没有像束文件那样被打包.这是一个简单的例子;
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"}]}.
Run Code Online (Sandbox Code Playgroud)
test.erl:
-module(test).
-export([main/1]).
main(_Args) ->
jiffy:decode(<<"1">>),
ok.
Run Code Online (Sandbox Code Playgroud)
rebar get-deps compile escriptize ./test
结果是
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 …Run Code Online (Sandbox Code Playgroud)