linux新手可能会遇到这个问题。
第6章Port drivers中
Erlang Interoperability Tutorial文档第6章Port drivers中有几个文字错误,影响编译
gcc -I/usr/local/lib/erlang/usr/include/ -o example_drv[color=red][b].so[/b][/color] -fpic -shared complex.c port_driver.c
要带.so的后缀名才行,不然装载例子中的静态库时会出现如下错误
exception exit: {error,{open_error,-10}}
我猜open_error,-10的意思应该是找不着某些库,错误代码在哪儿查我还没找到地方,先记下
另外要小心的是,在DRIVER_INIT返回的port driver entry结构中有一成员指定了erl_ddll:open_port函数的参数,所以共享库的名字还不能随便取
编译环境:RedHat linux
在MacOSX下
gcc 4.2下去掉-bundle
参见:
http://www.wagerlabs.com/blog/2008/02/erlang-ffi---in.html
第5章中的编译命令
记得加上线程库
第6章Port drivers中
Erlang Interoperability Tutorial文档第6章Port drivers中有几个文字错误,影响编译
gcc -I/usr/local/lib/erlang/usr/include/ -o example_drv[color=red][b].so[/b][/color] -fpic -shared complex.c port_driver.c
要带.so的后缀名才行,不然装载例子中的静态库时会出现如下错误
exception exit: {error,{open_error,-10}}
我猜open_error,-10的意思应该是找不着某些库,错误代码在哪儿查我还没找到地方,先记下
另外要小心的是,在DRIVER_INIT返回的port driver entry结构中有一成员指定了erl_ddll:open_port函数的参数,所以共享库的名字还不能随便取
编译环境:RedHat linux
在MacOSX下
gcc -I/opt/local/lib/erlang/usr/include/ -L/opt/local/lib/erlang/usr/lib/ -o example_drv.so -fpic -shared -bundle -flat_namespace -undefined suppress -fno-common complex.c port_driver.c
gcc 4.2下去掉-bundle
gcc -o example_drv.so -fpic -shared -flat_namespace -undefined suppress -fno-common -I/usr/local/lib/erlang/usr/include -L/usr/local/lib/erlang/usr/lib/ complex.c port_driver.c
参见:
http://www.wagerlabs.com/blog/2008/02/erlang-ffi---in.html
第5章中的编译命令
gcc -o extprg -I/usr/local/lib/erlang/lib/erl_interface-3.5.9/include/ \
-L/usr/local/lib/erlang/lib/erl_interface-3.5.9/lib/ \
complex.c erl_comm.c ei.c \
-lerl_interface -lei -lpthread
记得加上线程库