<div dir="ltr"><div><div><div><div>Hello,<br></div>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).<br></div>So I would like to test the NIF in an executable like this:<br>
<br>static ERL_NIF_TERM nif_myfunc(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {<br></div><div>    ... do something with enif and native functions ...<br></div><div>}<br><br>void main() {<br>    ErlNifEnv *env = enif_alloc_env();<br>
    nif_myfunc(env, 0, 0);<br>}<br><br></div>But it seems enif_alloc_env is not present in any lib*.a or *.so that gets generated when I build erlang.<br>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.<br>
<br>So, is there a simple way I can do this?<br></div><div><div><div><br></div><div>Regards,<br></div><div>Takeshi<br></div></div></div></div>