Compile and install Lua Module(C API)

Install lua_devel:

cd /usr/local/include
wget -O lua_devel.tar.gz https://www.dropbox.com/s/66zxd9gvdf7lvib/lua_devel.tar.gz?dl=0 --no-check-certificate
tar -xzf lua_devel.tar.gz
rm lua_devel.tar.gz

Download and compile lua-cjson:

cd /mnt/sda1/
wget http://www.kyne.com.au/~mark/software/download/lua-cjson-2.1.0.tar.gz
tar -xzf lua-cjson-2.1.0.tar.gz
cd /mnt/sda1/lua-cjson-2.1.0

gcc -c -O3 -Wall -pedantic -DNDEBUG  -I/usr/local/include -fpic -o lua_cjson.o lua_cjson.c
gcc -c -O3 -Wall -pedantic -DNDEBUG  -I/usr/local/include -fpic -o strbuf.o strbuf.c
gcc -c -O3 -Wall -pedantic -DNDEBUG  -I/usr/local/include -fpic -o fpconv.o fpconv.c
gcc  -shared -o cjson.so lua_cjson.o strbuf.o fpconv.o

Install lua-cjson:

cp cjson.so /usr/lib/lua/

Testing lua-cjson:

nano /mnt/sda1/arduino.lua

#!/usr/bin/lua
-------simple data-------
local tab ={}
tab["arduino"] = "arduino.cc"
--encode json -------
local cjson = require "cjson"
local jsonData = cjson.encode(tab)

print(jsonData) 
-- print result:  {"arduino":"arduino.cc"}

--decode json -------
local data = cjson.decode(jsonData)

print(data.arduino) 
-- print result:  arduino.cc
root@Arduino:/mnt/sda1# chmod 755 arduino.lua
root@Arduino:/mnt/sda1# ./arduino.lua
{"arduino":"arduino.cc"}
arduino.cc

lua-cjson (C-API) V.S. pure lua json module performance boost 1000% to 2000%!