mpx / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua
https://kyne.au/~mark/software/lua-cjson.php
MIT License
924 stars 474 forks source link

Lua 5.1.5 fails to load cjson or cjson.safe #83

Closed 4mig4 closed 1 year ago

4mig4 commented 1 year ago

Using Lua 5.1.5

On Rocky Linux 8.7

Luarocks compiles and installs it with no problem :

$ luarocks install lua-cjson 
Warning: falling back to wget - install luasec to get native HTTPS support
Installing https://luarocks.org/lua-cjson-2.1.0.10-1.src.rock

lua-cjson 2.1.0.10-1 depends on lua >= 5.1 (5.1-1 provided by VM)
gcc -O2 -fPIC -I/home/user1/.luaver/lua/5.1.5/include -c lua_cjson.c -o lua_cjson.o
gcc -O2 -fPIC -I/home/user1/.luaver/lua/5.1.5/include -c strbuf.c -o strbuf.o
gcc -O2 -fPIC -I/home/user1/.luaver/lua/5.1.5/include -c fpconv.c -o fpconv.o
gcc  -shared -o cjson.so lua_cjson.o strbuf.o fpconv.o
lua-cjson 2.1.0.10-1 is now installed in /home/user1/.luaver/luarocks/3.9.2_5.1 (license: MIT)

However when issuing a require on it it fail:

/usr/bin/lua: error loading module 'cjson.safe' from file '/home/user1/lib/lua/5.1/cjson/safe.so':
        /home/user1/lib/lua/5.1/cjson/safe.so: undefined symbol: lua_pcall
stack traceback:
        [C]: in ?
        [C]: in function 'require'
        ./sgce_check.lua:4: in main chunk
        [C]: in ?
4mig4 commented 1 year ago

My bad . closing it was the fault of #!/usr/bin/lua instead of #!/usr/bin/env lua , thus not using my luaver env but the default system lua!