Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol not found: _lua_objlen #56

Open
ktalebian opened this issue May 10, 2018 · 9 comments
Open

Symbol not found: _lua_objlen #56

ktalebian opened this issue May 10, 2018 · 9 comments

Comments

@ktalebian
Copy link

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 ?
@jamespenick
Copy link

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.

@MaG21
Copy link

MaG21 commented Jun 5, 2018

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

@peter-evans
Copy link

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

@kidlj
Copy link

kidlj commented May 17, 2019

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.

@e-moe
Copy link

e-moe commented Dec 13, 2019

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

@VVatashi
Copy link

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 ?

@MaMo7x
Copy link

MaMo7x commented Dec 5, 2021

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 . .

@mecampbellsoup
Copy link

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

@kaklakariada
Copy link

kaklakariada commented Mar 23, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants