<div dir="ltr">The NIF API is made to be used in the presence of a running emulator, so I don't think this approach will ever work.  Some suggestions:<div><br></div><div>1. Debug with printf().</div><div>2. Take your approach above but rip out all the NIF APIs to see if *that* works.</div>
<div><br></div><div>Dan.</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Apr 26, 2014 at 9:38 AM, mayamatakeshi <span dir="ltr"><<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>