[erlang-questions] problem when use g++ to compile erl_nif

Dave Smith dizzyd@REDACTED
Tue Mar 30 08:39:11 CEST 2010


Take a look at the ebloom project:

http://hg.basho.com/ebloom/

That's a NIF which wraps a C++ header-style bloom filter.

Bottom line, you need to include erl_nif.h in a separate header and
then make sure that all the stuff required by erlang happens in a
extern "C" section.

D.

On Tue, Mar 30, 2010 at 12:34 AM, caox <caox@REDACTED> wrote:
> I am trying to use erl_nif to implement some drivers.And I am wondering if
> there is any way to compile  nif files with g++, just like what
>
> #ifdef __cplusplus
> extern "C" { // shouldn't this be in the DRIVER_INIT macro?
> #endif
> DRIVER_INIT(template_drv) {
>    return &template_drv_entry;
> }
> #ifdef __cplusplus
> }
> #endif
>
> can do for erl_driver. In that way, it will be more convenient to code with
> c++ libs.
> But now, I got an error when using g++ to run the example with OTPR1303:
>
> g++ -shared -fpic -ldl -I/usr/lib64/erlang/usr/include -I/usr/include
> -I/usr/lib64/erlang/lib/erl_interface-3.6.4/include
> -I/mnt/hgfs/work/ewp_new_trunk/drivers/template
> -I/mnt/hgfs/work/vendor/clearsilver-0.10.5 -o ./priv/niftest.so
> c_src/niftest.c -L/usr/lib64/erlang/lib/erl_interface-3.6.4/lib
> -L/usr/lib64/erlang/usr/lib -lei -lxerces-c   -lxqilla
>  -L/mnt/hgfs/work/vendor/clearsilver-0.10.5/libs -lneo_cs -lneo_cgi
> -lneo_utl
> c_src/niftest.c:28: error: invalid conversion from ‘ERL_NIF_TERM
> (*)(ErlNifEnv*)’ to ‘void*’
> make: *** [nif] Er/
>
> Appreciate your help.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list