starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.71k stars 388 forks source link

symbol not found in flat namespace '_luaL_checkversion_' #243

Closed BennyTian closed 1 year ago

BennyTian commented 1 year ago

os: Mac m1

install:

git clone https://github.com/starwing/lua-protobuf
luarocks make rockspecs/lua-protobuf-scm-1.rockspec

cp pb.so pb.o protoc.lua $MYPATH/openresty/lualib

test.lua:

local pb = require("pb")

execption:

2023/05/08 22:23:26 [error] 79471#5350509: *329 lua entry thread aborted: runtime error: error loading module 'pb' from file '/opt/homebrew/Cellar/openresty/1.21.4.1_2/lualib/pb.so':
    dlopen(/opt/homebrew/Cellar/openresty/1.21.4.1_2/lualib/pb.so, 0x0006): symbol not found in flat namespace '_luaL_checkversion_'
BennyTian commented 1 year ago

在作者的解答下,找到问题:

openresty 的 luajit 版本 和 luarocks 依赖的 lua 版本不一致.

修改编译方法,不使用 luarocks , 而是使用 gcc手动编译,手动指定lua的c库为openresty luajit 下的库文件:

gcc -O2 -I /opt/homebrew/opt/openresty/luajit/include/luajit-2.1 -shared -undefined dynamic_lookup pb.c -o pb.so