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 ...
随机推荐
- Input的readonly 属性与disabled属性
readonly 不可编辑,可以获得焦点,背景颜色默认灰色,值的字体颜色默认为灰色,值可以在请求中传递 disabled 不可编辑,不可以获得焦点,背景颜色默认灰色,值的字体颜色默认为灰色,值不可以在 ...
- ACM HDU 2674 N! Again(数论)
继续数论.. Problem Description WhereIsHeroFrom: Zty,what are you doing ? Zty: ...
- 《ln命令》-linux命令五分钟系列之十八
本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...
- 闭包 this,arguemnts 问题
因为每个函数在被调用时,其活动对象都会自动取得两个特殊的变量,this和arguments.内部函数的搜索这两个变量时,只会搜索到其活动对象为止.因此永远不可能直接访问到外部函数中的这两个变量 ...
- css3学习--css3动画详解二(3d效果)
一.设置3D场景 perspective:800 //浏览器到物体的距离(像素)perspective-origin:50% (x轴) 50% (y轴) //视点的位置 transf ...
- 机器学习系列(17)_Yelper推荐系统
1. 我们为什么需要推荐系统?“推荐”可是个当红话题.Netflix愿意用百万美金召求最佳的电影推荐算法,Facebook也为了登陆时的推荐服务开发了上百个项目,遑论现在市场上各式各样的应用都需要个 ...
- 研究在SAE上搭建最新wordpress
安装SAE上的wordpress,创建应用选择wordpress模板,安装后是3.4版本 新建一个版本2,下载最新wordpress安装包并解压到版本2中 初步猜想修改地方: 数据库配置:wp-con ...
- Global & Local Variable in Python
Following code explain how 'global' works in the distinction of global variable and local variable. ...
- Python中使用中文
python的中文问题一直是困扰新手的头疼问题,这篇文章将给你详细地讲解一下这方面的知识.当然,几乎可以确定的是,在将来的版本中,python会彻底解决此问题,不用我们这么麻烦了. 先来看看pytho ...
- uboot全局变量
一.global_data(include/asm-arm/global_data.h) typedef struct global_data { bd_t *bd; unsigned long fl ...