Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you setup an Erlang NIF project with rebar?
    text
    copied!<p>I looked through the questions here on StackOverflow and Googled around for an example of setting up a Basic NIF project in rebar for wrapping a C++ library. </p> <p>I used to library project on GitHub as a guide: </p> <p><a href="https://github.com/tuncer/re2" rel="nofollow">https://github.com/tuncer/re2</a></p> <p>My project is here: </p> <p><a href="https://github.com/project-z/emutton/" rel="nofollow">https://github.com/project-z/emutton/</a></p> <p>When I do a <code>rebar compile &amp;&amp; rebar eunit</code>, I get a failure in the eunit test because it cannot find <code>emtn.so</code>: </p> <pre><code>$ rebar compile &amp;&amp; rebar eunit ==&gt; emutton (compile) ==&gt; emutton (eunit) undefined *** test module not found *** **emtn =ERROR REPORT==== 25-Jun-2013::12:21:55 === The on_load function for module emtn returned {error, {load_failed, "Failed to load NIF library: 'dlopen(/.../source/emutton/priv/emtn.so, 2): image not found'"}} ======================================================= Failed: 0. Skipped: 0. Passed: 0. One or more tests were cancelled. ERROR: One or more eunit tests failed. ERROR: eunit failed while processing /.../source/emutton: rebar_abort </code></pre> <p>When I call <code>rebar compile</code>, it is only producing a single driver file, <code>emtn_drv.so</code> and no <code>emtn.so</code>: </p> <pre><code>$ tree priv priv └── emtn_drv.so 0 directories, 1 file </code></pre> <p>I have an echo statement in <code>c_src/build_deps.sh</code> that I don't see output when I call <code>rebar clean</code>. It seems to behave as though my <code>pre_hook</code> and <code>post_hook</code> in <code>rebar.config</code> are completely ignored: </p> <pre><code>{pre_hooks, [{compile, "c_src/build_deps.sh"}]}. {post_hooks, [{clean, "c_src/build_deps.sh clean"}]}. </code></pre> <p>Examples of no output shown from <code>rebar</code>: </p> <pre><code>$ rebar compile ==&gt; emutton (compile) $ rebar clean ==&gt; emutton (clean) </code></pre> <p>Because I have cloned tuncer's RE2 bindings project and when I do a <code>rebar compile</code> see output from his build_deps.sh script. The permissions on mine match those on his: </p> <pre><code>-rwxr-xr-x 1 ajl staff 891B Jun 25 12:30 c_src/build_deps.sh </code></pre> <p>Any idea what I'm missing here? I believe that rebar is configured correctly to call out to the script and do the compilation. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload