[erlang-questions] Linking enif_* functions to an executable file

mayamatakeshi mayamatakeshi@REDACTED
Sat Apr 26 16:38:33 CEST 2014


Hello,
I am having trouble to debug a NIF library that I wrote (and somehow I
cannot make gcc to stop when a crash happens in it).
So I would like to test the NIF in an executable like this:

static ERL_NIF_TERM nif_myfunc(ErlNifEnv *env, int argc, const ERL_NIF_TERM
argv[]) {
    ... do something with enif and native functions ...
}

void main() {
    ErlNifEnv *env = enif_alloc_env();
    nif_myfunc(env, 0, 0);
}

But it seems enif_alloc_env is not present in any lib*.a or *.so that gets
generated when I build erlang.
I tried to link to the beam (renamed as libbeam.a)) but i got the linker to
segfault. So I might need to extract these definitions or extract them from
the beam source code and add it to my app, but it looks too much trouble.

So, is there a simple way I can do this?

Regards,
Takeshi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140426/29ee04c8/attachment.htm>


More information about the erlang-questions mailing list