mpx / lua-cjson

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

Error on require #30

Closed rumkin closed 8 years ago

rumkin commented 8 years ago

Got error requiring cjson:

/apps/nginx/lua-cjson/cjson.so:1: unexpected symbol near 'char(127)'

cjson was built with command:

make LUA_INCLUDE_DIR=/usr/include/lua5.2
mpx commented 8 years ago

The error indicates that "cjson.so" is being interpreted as a Lua source file, not a plugin.

I'm not familiar with your nginx configuration, but I suspect the Lua package.path incorrectly includes the "?.so" file. Eg:

$ lua
Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> package.path = "./?.so"
> require "cjson"
error loading module 'cjson' from file './cjson.so':
    ./cjson.so:1: unexpected symbol near char(127)
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: in ?

The path settings can usually be set with LUA_PATH/LUA_CPATH environment variables, package.path/package.cpath (within Lua), or some custom application configuration (Nginx).

rumkin commented 8 years ago

Yep, it works. I've mixed up path and cpath. Sorry for that and thanks for answer!

rumkin commented 8 years ago

And now I've got )

lua-cjson/cjson.so: undefined symbol: luaL_setfuncs
rumkin commented 8 years ago

Solved.