Erlang Interoperability Tutorial文档中的例子

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 -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


记得加上线程库
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值