[erlang-questions] NIFS

Karlo Kuna kuna.prime@REDACTED
Tue Feb 7 23:04:44 CET 2017


For everyones amusement and information. I have overlooked something
important as a noob and then some.
Compiling and linking where done in two steps, and i have reused makefile
form another project not realizing that
linking step would be done by "cc" and that was the problem, changing it to
for example g++ resolved my issue.

This was one of those costly errors, when one stares at build output for
very long time and not seeing things that are
plainly there.

thank you everyone for help

On Sun, Feb 5, 2017 at 11:11 AM, Mikael Pettersson <mikpelinux@REDACTED>
wrote:

> Karlo Kuna writes:
>  > also
>  > ldd -r my.so
>  > gives:
>  > undefined symbol: _ZNSt8ios_base4InitD1Ev
>  > undefined symbol: enif_make_atom
>  > undefined symbol: _ZNSt8ios_base4InitC1Ev
>
> The enif_make_atom one is expected; it will be satisfied by the VM itself
> when you load the .so.
>
> The others indicate that the dynamic linker is unable to find all external
> shared libraries you depend on, in particular ones that should have come
> from the system's C++ / libstdc++ installation.
>
> Something's fishy with your system or your build/deploy procedures.
>
>  >
>  >
>  >
>  > On Sun, Feb 5, 2017 at 6:48 AM, Karlo Kuna <kuna.prime@REDACTED>
> wrote:
>  >
>  > > now i'm getting:
>  > > undefined symbol: _ZNSt8ios_base4InitD1Ev
>  > >
>  > >
>  > >
>  > > On Sat, Feb 4, 2017 at 11:45 PM, Stanislaw Klekot <
> erlang.org@REDACTED>
>  > > wrote:
>  > >
>  > >> On Sat, Feb 04, 2017 at 11:25:33PM +0100, Karlo Kuna wrote:
>  > >> > i am using c++ to implement nif module
>  > >> > and i am using nifpp (https://github.com/goertzenator/nifpp)
>  > >> >
>  > >> > now i can compile my project but on function call i get:
>  > >> >
>  > >> > Failed to load NIF library: my.so undefined symbol:
>  > >> > _ZTVN10__cxxabiv117__class_type_infoE
>  > >> >
>  > >> > can someone give me a hint what is this error?  is it linkage, or
> bad
>  > >> call,
>  > >> > or something else
>  > >> > and how go about solving it?
>  > >>
>  > >> It's because of name mangling by C++ compiler (necessary thing for
>  > >> overloaded functions to work). It's a totally expected problem when
>  > >> you're writing in C++ a library that needs to be used by system
> written
>  > >> in C. You need to disable name mangling for your NIF function.
>  > >>
>  > >> --
>  > >> Stanislaw Klekot
>  > >>
>  > >
>  > >
>  >
>  > ----------------------------------------------------------------------
>  > _______________________________________________
>  > erlang-questions mailing list
>  > erlang-questions@REDACTED
>  > http://erlang.org/mailman/listinfo/erlang-questions
>
> --
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170207/067dba13/attachment.htm>


More information about the erlang-questions mailing list