problem when use g++ to compile erl_nif

caox caox@REDACTED
Tue Mar 30 08:34:25 CEST 2010


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.


More information about the erlang-questions mailing list