starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.75k stars 387 forks source link

undefined symbol: luaL_prepbuffer #83

Closed CatCodeMe closed 4 years ago

CatCodeMe commented 5 years ago

issue

CatCodeMe commented 5 years ago

根据知乎中文说明,编写的aa.lua

CatCodeMe commented 5 years ago

使用gcc安装已成功

starwing commented 5 years ago

Lua不同大版本二进制是不兼容的

CatCodeMe commented 5 years ago

大佬,我发现原因了。

  1. 当我使用 luarocks install lua-protobuf安装时,
    • /usr/local/share/lua/5.1/ 生成 protoc.lua 源文件
    • /usr/local/lib/lua/5.1/ 生成 pb.so源文件
    • 这种方式下,引用pb.so会报错,
      • e.g. ./pb.so: undefined symbol: lua_tointegerx, 这个好像就是因为lua版本的问题
  2. 但是当我使用 README文档 gcc -O2 xxxxxx 手动编译生成 pb.so文件,此时引用不会有问题
    • 我目前只使用了encodedecode,没有遇到问题
  3. 我对比了一下两版pb.so文件的md5,竟然不一样。所以我怀疑是不是luarock的锅。
starwing commented 5 years ago

你luarocks使用的lua可能和系统安装的不一样,你查询一下luarocks(应该有类似info的命令)使用的Lua到底是装在哪儿的