我尝试在ei库中使用erlang中的C代码。
我尝试使用以下命令构建代码:
-I/usr/local/lib/erlang/erts-5.8.5/include/ -I/usr/local/lib/erlang/lib/erl_interface-3.7.5/include -O2 -g3 -Wall -c -fmessage-length=0但我得到的错误是ei函数未定义引用。
我的简单代码:
int main(void) {
ei_x_buff result;
ei_x_encode_atom(&result, "ok");
return 0;
}
undefined reference to `ei_x_encode_atom'我怎么才能修复它?
谢谢。
发布于 2012-01-20 01:55:41
未定义的引用是链接器错误。这意味着你需要将你的代码链接到erl_interface库中。
实际上,您需要使用-L选项来指向erl_interface库所在位置,并使用-l选项来指定要链接的库。
有点
ld -L/usr/local/otp/lib/erl_interface-3.2.3/lib \
myprog.o -lerl_interface -lei -o myprog(这是文档中的示例)
https://stackoverflow.com/questions/8928422
复制相似问题