[erlang-questions] NIFS

Karlo Kuna <>
Sun Feb 5 09:42:30 CET 2017


problem is that i am already using "extern C" declaration,

and as far as symbol names i'm relying on compiler

so far i have noticed that some problems go away if i don't include some
headers (iostream) and that's fine
but now when i try to use std::string in nif implementation, when i call it
i get:

{load_failed,"Failed to load NIF library: './priv/my.so: undefined
symbol: __gxx_personality_v0'"


On Sun, Feb 5, 2017 at 9:01 AM, zv <> wrote:

> I'm not familiar with ~nifpp~ in particular, but if you are receiving an
> error like
>
> > undefined symbol: enif_make_atom
>
> There are underlying issues beyond symbol mangling.
>
> I assume you are including erl_nif.h, directly or otherwise. As far as the
> mangling is concerned, you haven't made it clear if you are using objdump
> to extract the correct symbol name or if you are relying on the compiler,
> although Stanislaw has already mentioned the issue so you have a thread to
> follow.
>
> If you are getting an 'undefined symbol' on function call, you are
> dynamically linking your library, which means you need to make sure that
> your library is on the linker path during runtime as that's how the dynamic
> library loader will find it (which happens when you load the nif in Erlang,
> it spiders out to the libraries that library needs until it can resolve all
> the required symbols).
>
> An alternative approach would be to make your my.so a static library my.a
> and then link your nif against that which removes some of these issues in
> finding libraries.
>
> You also might want to just consider an "extern C" linkage declaration,
> totally bypassing any mangling or other C++ symbol decoration
> idiosyncrasies.
>
> - zephyr
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170205/bd7cb605/attachment.html>


More information about the erlang-questions mailing list