找不到符号:_lua_objlen

Symbol not found: _lua_objlen

我正在使用 lua-cjson

package.path = package.path .. ";../?.lua"
local json = require('cjson')

我得到:

lua: error loading module 'cjson' from file '/usr/local/lib/lua/5.3/cjson.so':
        dlopen(/usr/local/lib/lua/5.3/cjson.so, 6): Symbol not found: _lua_objlen
  Referenced from: /usr/local/lib/lua/5.3/cjson.so
  Expected in: flat namespace
 in /usr/local/lib/lua/5.3/cjson.so
stack traceback:
        [C]: in ?
        [C]: in function 'require'
        log.lua:6: in main chunk
        [C]: in ?

有什么想法吗?使用 lua 5.3

似乎刚刚在 github 上针对这个问题打开了一个问题:https://github.com/mpx/lua-cjson/issues/56。对于它的价值,这是我在 github:

上发布的解决方法

我在 alpine linux 上看到与 lua-cjson 2.1.0.6-1 版相同的问题,我目前正在通过明确指定 2.1 版来解决这个问题。 0-1.

降级到 2.1.0-1 如@James Penick

所述
luarocks remove lua-cjson
luarocks install lua-cjson 2.1.0-1

Installing https://luarocks.org/lua-cjson-2.1.0-1.src.rock
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c lua_cjson.c -o lua_cjson.o
In file included from lua_cjson.c:47:
./fpconv.h:15:20: warning: inline function 'fpconv_init' is not defined [-Wundefined-inline]
extern inline void fpconv_init();
                   ^
lua_cjson.c:1359:5: note: used here
    fpconv_init();
    ^
1 warning generated.
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c strbuf.c -o strbuf.o
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c fpconv.c -o fpconv.o
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -bundle -undefined dynamic_lookup -all_load -o cjson.so -L/usr/local/lib lua_cjson.o strbuf.o fpconv.o
lua-cjson 2.1.0-1 is now installed in /usr/local (license: MIT)

问题与安装lua-cjson-2.1.0.6-1

时的警告信息有关
Installing https://luarocks.org/lua-cjson-2.1.0.6-1.src.rock
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/include -c lua_cjson.c -o lua_cjson.o
lua_cjson.c:743:19: warning: implicit declaration of function 'lua_objlen' is invalid in C99 [-Wimplicit-function-declaration]
            len = lua_objlen(l, -1);
                  ^
1 warning generated.