如果我自己编写 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"}]}.
test.erl
:
-module(test).
-export([main/1]).
main(_Args) ->
jiffy:decode(<<"1">>),
ok.
rebar get-deps 编译 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 call from init:start_em/1
有没有办法克服这个?