Can rebar3 build binary instead of shared lib .so (NIF)?

Hi rebar3 experts,

I’m wondering if rebar3 (using port_compiler plugin or anything else) can build a binary (priv/mybin) from a bunch of C files under c_src/*.c ?

The idea is to run this binary from within the VM using erlang:open_port/2.
Thanks

  • Erlang 24.3.4.6
  • Rebar3 v3.19.0
  • port_compiler 1.10.2
  • Ubuntu 20.04 LTS
2 Likes

Answering my own question. I’m using a build script and relying on the following hooks.

{pre_hooks, [{compile, "c_src/build_deps.sh"}]}.
{post_hooks, [{clean, "c_src/build_deps.sh clean"}]}.
3 Likes

Sounds good you have resolved it

1 Like

You can take a look at how erlexec is built.

1 Like