Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symbol not found: _lua_objlen

Tags:

lua

luarocks

I'm using lua-cjson

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

And I'm getting:

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 ?

Any ideas? Using lua 5.3

like image 408
Kousha Avatar asked May 10 '18 20:05

Kousha


2 Answers

Downgrade to 2.1.0-1 as mentioned by @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)

The problem is related to the warning message when installing 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.
like image 169
ejlp12 Avatar answered Nov 10 '22 23:11

ejlp12


It looks like an issue was just opened on github for this problem: https://github.com/mpx/lua-cjson/issues/56. For what it's worth, here's the workaround that I posted on github:

I'm seeing the same issue on alpine linux with with version 2.1.0.6-1 of lua-cjson, I'm currently working around the issue by explicitly specifying version 2.1.0-1.

like image 22
neoeuphemism Avatar answered Nov 10 '22 21:11

neoeuphemism