lua-cjson icon indicating copy to clipboard operation
lua-cjson copied to clipboard

Symbol not found: _lua_objlen

Open ktalebian opened this issue 6 years ago • 9 comments

I'm requiring the module using

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 ?

ktalebian avatar May 10 '18 20:05 ktalebian

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.

jamespenick avatar May 10 '18 23:05 jamespenick

$ luarocks remove lua-cjson
$ luarocks install lua-cjson 2.1.0-1

MaG21 avatar Jun 05 '18 15:06 MaG21

lua-cjson on luarocks seems to be Openresty's version, not this code base. See this issue there: https://github.com/openresty/lua-cjson/issues/36

peter-evans avatar Jun 28 '18 14:06 peter-evans

I'm having the same issue on macOS with Lua-5.3.5.

I have to remove the latest lua-cjson(2.1.0.6-1) and install a previous version(2.1.0-1) instead.

kidlj avatar May 17 '19 10:05 kidlj

same issue: macOS 10.15.1 (19B88); Lua-5.3.5; lua-cjson(2.1.0.6-1)

e-moe avatar Dec 13 '19 09:12 e-moe

Still have the same problem on the Arch linux when installing it from the luarocks.

$ sudo luarocks install lua-cjson
Installing https://luarocks.org/lua-cjson-2.1.0.6-1.src.rock

gcc -O2 -fPIC -I/usr/include -c lua_cjson.c -o lua_cjson.o
lua_cjson.c: In function 'json_append_data':
lua_cjson.c:743:19: warning: implicit declaration of function 'lua_objlen'; did you mean 'lua_len'? [-Wimplicit-function-declaration]
  743 |             len = lua_objlen(l, -1);
      |                   ^~~~~~~~~~
      |                   lua_len
gcc -O2 -fPIC -I/usr/include -c strbuf.c -o strbuf.o
gcc -O2 -fPIC -I/usr/include -c fpconv.c -o fpconv.o
gcc -shared -o cjson.so lua_cjson.o strbuf.o fpconv.o
lua-cjson 2.1.0.6-1 is now installed in /usr (license: MIT)

And then when I run a script:

$ lua test.lua
lua: error loading module 'cjson' from file '/usr/lib/lua/5.3/cjson.so':
	/usr/lib/lua/5.3/cjson.so: undefined symbol: lua_objlen
stack traceback:
	[C]: in ?
	[C]: in function 'require'
	test.lua:1: in main chunk
	[C]: in ?

VVatashi avatar Dec 14 '19 06:12 VVatashi

I found the fix . . . http://lua-users.org/lists/lua-l/2018-03/msg00447.html on this link it is stated that lua_objlen was renamed to lua_rawlen . . . so renaming lua_objlen:lua_cjson.c:743 to lua_rawlen solves the issue. Here is what I did to build the latest release . . . $ luarocks download lua_cjson $ luarocks unpack lua_cjson $ cd lua-cjson-2.1.0.6-1/lua-cjson edit the lua_cjson.c file using your favourite editor and change lua_objlen -> lua_rawlen then, $ luarocks make BOOM! it compiles fine . .

MaMo7x avatar Dec 05 '21 21:12 MaMo7x

This issue is still open after almost 4 years, is this project not maintained?

mecampbellsoup avatar Dec 28 '21 18:12 mecampbellsoup

I managed to install the latest version with the following command:

luarocks install lua-cjson --local "CFLAGS=-O3 -Wall -pedantic -DNDEBUG -DLUA_COMPAT_5_3"

The important part is -DLUA_COMPAT_5_3.

kaklakariada avatar Mar 23 '22 13:03 kaklakariada