luajit 安装cjson
最近需要升级原有服务器的nginx加载逻辑,新的lua脚本需要解析一个远程返回的json格式的结果,原有的luajit并没有带cjson库,需要自己手动安装一下。
基本参考博客luajit安装cjson。
cjson下载地址:http://www.kyne.com.au/~mark/software/lua-cjson.php
下载文件 lua-cjson-2.1.0.tar.gz
运行命令
tar -zxvf lua-cjson-2.1..tar.gz cd lua-cjson-2.1.0 make
make命令在使用默认配置下报错
lua_cjson.c::: error: lua.h: No such file or directory
lua_cjson.c::: error: lauxlib.h: No such file or directory
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
lua_cjson.c:: error: expected ‘)’ before ‘*’ token
根据上述博客和之前安装luasocket的经验,还是没有找到lua源码进行编译报的错。
find 一下lua.h这个文件,发现位于/opt/luajit-2.0.0/include/luajit-2.0路径下。
修改Makefile文件,修改default配置为
## multi-threaded application. Requries _pthreads_. ##### Build defaults #####
LUA_VERSION = 5.1
TARGET = cjson.so
PREFIX = /opt/luajit-2.0.
#CFLAGS = -g -Wall -pedantic -fno-inline
CFLAGS = -O3 -Wall -pedantic -DNDEBUG
CJSON_CFLAGS = -fpic
CJSON_LDFLAGS = -shared
#LUA_INCLUDE_DIR = $(PREFIX)/include
LUA_INCLUDE_DIR = /opt/luajit-2.0./include/luajit-2.0
LUA_CMODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION)
LUA_MODULE_DIR = $(PREFIX)/share/lua/$(LUA_VERSION)
LUA_BIN_DIR = $(PREFIX)/bin
主要是修改了LUA_INCLUDE_DIR用于安装cjson;修改了PREFIX变量用来改变编译结果文件输出的路径
保存修改,执行命令
make && make install
cc -c -O3 -Wall -pedantic -DNDEBUG -I/opt/luajit-2.0./include/luajit-2.0 -fpic -o lua_cjson.o lua_cjson.c
cc -c -O3 -Wall -pedantic -DNDEBUG -I/opt/luajit-2.0./include/luajit-2.0 -fpic -o strbuf.o strbuf.c
cc -c -O3 -Wall -pedantic -DNDEBUG -I/opt/luajit-2.0./include/luajit-2.0 -fpic -o fpconv.o fpconv.c
cc -shared -o cjson.so lua_cjson.o strbuf.o fpconv.o
mkdir -p //opt/luajit-2.0.0/lib/lua/5.1
cp cjson.so //opt/luajit-2.0.0/lib/lua/5.1
chmod //opt/luajit-2.0.0/lib/lua/5.1/cjson.so
输出结果显示正确,安装成功
luajit 安装cjson的更多相关文章
- 安装 luajit && 给 luajit 安装 cjson
安装 luajit 步骤: 从官网 http://luajit.org/download.html下载 LuaJIT-2.0.5.tar.gz 解压 tar -xzf LuaJIT-2.0.5.ta ...
- nginx的luajit安装luarocks并安装luafilesystem
nginx的luajit安装luarocks并安装luafilesystem by admin on -- :: in , 69次 标题有点绕口.我尽量把关键词都贴进去.之前因为自己的nginx安装了 ...
- lua 的 cjson 安装,使用
1. 背景: 虚拟机安装的luajit 没有 cjson 库,就不能对 table 进行 编码操作,手动安装一个. 2. 安装: cjson下载地址:http://www.kyne.com.au/~ ...
- Redis进阶实践之八Lua的Cjson在Linux下安装、使用和用C#调用Lua脚本
一.引言 学习Redis也有一段时间了,感触还是颇多的,但是自己很清楚,路还很长,还要继续.上一篇文章简要的介绍了如何在Linux环境下安装Lua,并介绍了在Linux环境下如何编写L ...
- 【LuaJIT版】从零开始在 macOS 上配置 Lua 开发环境
前言 这篇文章针对的是基于 LuaJIT 的环境配置.借助于 LuaJIT,Lua 的执行效率可以进一步提升几十倍.如果你不是很清楚自己是需要 Lua 还是 LuaJIT,那么建议你从 LuaJIT ...
- 手动编译 Nginx 并安装 VeryNginx
VeryNginx 是个非常有意思且便捷的 Nginx 扩展程序.最近新开了台 VPS,便想体验一下它带来的快感. VeryNginx 有个不超过 5 行的安装方法,但作为强迫症我更喜欢使用自己编译的 ...
- Nginx编译安装lua-nginx-module
lua-nginx-module 模块可以将Lua的强大功能嵌入NGINX服务器. 下载Nginx源码 如果已安装Nginx,需要查看当前安装版本的编译参数: $ /usr/local/nginx/s ...
- LNMP平滑升级nginx并安装ngx_lua模块教程
#ngx_lua module项目地址 https://github.com/chaoslawful/lua-nginx-module 在LNMP安装包后,重编译nginx,并添加ngx_lua模块 ...
- nginx+lua_module安装
1.LuaJit安装 # cd /usr/local/src # git clone http://luajit.org/git/luajit-2.0.git # cd luajit-2.0 # ma ...
随机推荐
- Linux 信号量互斥编程
所谓信号量,其实就是一个数字.内核给这个数字赋予一定的含义,让它等于不同的值时所表示的意义不同.这样就可以用它来标示某种资源是否正被使用.信号的分类其实挺多的,主要还是二值和计数器.这里讨论二值 现在 ...
- struts.xml文件示范
<?xml version="1.0" encoding="GBK"?> <!--下面指定Struts2配置文件的DTD信息--> &l ...
- transcode_step()在转码过程中对pts、dts、duration的处理
对pts.dts.duration的处理主要集中在两大函数里面 1.process_input()读入数据并处理,放到滤镜里面 2.reap_filters()从滤镜读出数据,处理后写入文件 proc ...
- #Leet Code# Root to leaf
语言:Python 描述:使用递归实现 def getList(self, node): if node is None: return [] if node.left is None and nod ...
- AVR GCC对端口的操作指南
1. AVR GCC for AVR I.I/O端口API1. BV用法:BV(pos);说明:将位定义转换成屏蔽码(MASK).与头文件io.h里的位定义一起使用.例如,置位WDTOE和WDE可表示 ...
- Start of Something New
Hi Guys This will be the blog of SCaffrey for some time before he creates his own site:) Have a nice ...
- eclipse 启动tomcat报Spring错误 Error creating bean with name 'serviceOrderBiz': Injection of autowired dependencies failed
启动tomcat报异常,提示Sring无法创建serviceOrderBiz(第一行红字),继续看是因为有一个自动注入的字段无法注入ModuleInterfaceBiz(第二行红字),检查servic ...
- python关键字
python有多少关键字? >>> import keyword >>> keyword.kwlist ['and', 'as', 'assert', 'break ...
- iOS开发(Objective-C)常用库索引
code4app.com 这网站不错,收集各种 iOS App 开发可以用到的代码示例 cocoacontrols.com/ 英文版本的lib收集 objclibs.com/ 精品lib的收集网站 h ...
- FLASH 存储学习-串行SPI NOR FLASH
1.1 SST25VF080B简介1.1.1 主要特性 关键点:容量.速度(时钟速度.读写速度).功耗. l 容量:8MBit: l 最高SPI时钟频率:50MHz: l 低功耗模式下电流消耗:5uA ...