转载请注明原文地址:http://www.cnblogs.com/dongxiao-yang/p/4878323.html

luasocket安装过程中遇到不少坑,之前采用的是从公司以前服务器的里面找一个其他同学下好的rpm安装包直接安装,安装的路径以及产生的库文件在什么位置都不知道怎么控制,今天抽时间一通google,终于跑通了源码安装的过程。

官方下载地址:http://files.luaforge.net/releases/luasocket/luasocket/luasocket-2.0.2

tar -zxvf  luasocket-2.0.2.tar.gz

cd luasocket-2.0.2

修改配置文件config

由于是在安装openresty后再安装luasocket,修改配置文件为,这样将制定luasocket生成的库文件放到openresty默认会寻找的路径下

INSTALL_TOP_SHARE=/opt/openresty/luajit/share/lua/5.1

INSTALL_TOP_LIB=/opt/openresty/luajit/lib/lua/5.1

参考http://blog.csdn.net/wzzfeitian/article/details/8866390教程介绍

make

这种情况下会报错

cd src; make all

make[1]: Entering directory `/opt/luasocket-2.0.2/src'

gcc -I/usr/share/lua/5.1 -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o luasocket.o luasocket.c

luasocket.c:20:17: error: lua.h: No such file or directory

luasocket.c:21:21: error: lauxlib.h: No such file or directory

luasocket.c:24:24: error: compat-5.1.h: No such file or directory

In file included from luasocket.c:30:

luasocket.h:30: error: expected ')' before '*' token

In file included from luasocket.c:31:

auxiliar.h:37: error: expected ')' before '*' token

auxiliar.h:38: error: expected ')' before '*' token

auxiliar.h:39: error: expected ')' before '*' token

auxiliar.h:40: error: expected ')' before '*' token

auxiliar.h:41: error: expected ')' before '*' token

auxiliar.h:42: error: expected ')' before '*' token

auxiliar.h:43: error: expected ')' before '*' token

auxiliar.h:44: error: expected ')' before '*' token

auxiliar.h:45: error: expected ')' before '*' token

auxiliar.h:46: error: expected ')' before '*' token

In file included from luasocket.c:32:

except.h:33: error: expected ')' before '*' token

In file included from luasocket.c:33:

timeout.h:19: error: expected ')' before '*' token

timeout.h:26: error: expected ')' before '*' token

In file included from luasocket.c:34:

buffer.h:39: error: expected ')' before '*' token

buffer.h:41: error: expected ')' before '*' token

buffer.h:42: error: expected ')' before '*' token

buffer.h:43: error: expected ')' before '*' token

buffer.h:44: error: expected ')' before '*' token

In file included from luasocket.c:35:

inet.h:27: error: expected ')' before '*' token

inet.h:35: error: expected ')' before '*' token

inet.h:36: error: expected ')' before '*' token

In file included from luasocket.c:36:

tcp.h:34: error: expected ')' before '*' token

In file included from luasocket.c:37:

udp.h:31: error: expected ')' before '*' token

In file included from luasocket.c:38:

select.h:15: error: expected ')' before '*' token

luasocket.c:43: error: expected ')' before '*' token

luasocket.c:44: error: expected ')' before '*' token

luasocket.c:45: error: expected ')' before '*' token

luasocket.c:50: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mod'

luasocket.c:60: warning: ISO C does not allow extra ';' outside of a function

luasocket.c:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'func'

luasocket.c:66: warning: ISO C does not allow extra ';' outside of a function

luasocket.c:71: error: expected ')' before '*' token

luasocket.c:80: error: expected ')' before '*' token

luasocket.c:89: error: expected ')' before '*' token

luasocket.c:113: error: expected ')' before '*' token

make[1]: *** [luasocket.o] Error 1

make[1]: Leaving directory `/opt/luasocket-2.0.2/src'

make: *** [all] Error 2

这个问题之前查了几次没有结果,看错误输出也一直以为是下的源码包有问题,下了好几个版本都不行,后来偶然看到了http://stackoverflow.com/questions/20490854/luasocket-c2017-error-lua-h-no-such-file-or-directory

有人遇到了同样的问题,生硬照搬答案里make LUAINC=-I/usr/include/lua5.1/的方法也没有解决,反而是看到问题的comment小字有人回复了一句话搞明白了问题的真正原因:

lua.h is the main header file for the Lua C source code. Either you don't have the lua source installed, or you haven't told the compiler where to find it. – Roddy Dec 10 '13 at 9:46

所以说其实是gcc编译命令找不到本机lua的源码到底在什么地方,自然无法编译。正好错误里提示lua.h这个文件找不到,find一下其实就在openresty的build/lua-5.1.5/src下。

修改config文件

LUAINC=-I/opt/ngx_openresty-1.9.3.1/build/lua-5.1.5/src

重新运行make&&make install 成功

再去检查下

INSTALL_TOP_SHARE=/opt/openresty/luajit/share/lua/5.1

INSTALL_TOP_LIB=/opt/openresty/luajit/lib/lua/5.1

这两个路径下socket库文件都已经存在了。

其实之前看http://www.linuxidc.com/Linux/2013-12/93516.htm的过程也提到了要修改LUAINC属性,只不过当时完全不知道这个是干嘛的就滑过去了,其实还是lua生的不行造成的~~~~~

opentesty--luasocket 安装的更多相关文章

  1. luasocket 安装记录 (FS1.4)

    说明:FS 1.4 使用的lua 5.2 ,需要使用luasocket 3.0 以上. 本文以FS 1.4 && luasocket 3.0 为基础,记录安装使用过程. 一.下载 &a ...

  2. luasocket 安装记录 (FS1.6)

    说明: 想通过Lua 脚本实现 http.默认 FS 的 mod_lua 中没有对socket 的支持,如下的操作为lua 添加 socket的支持. 一.下载 luasocket 包: # wget ...

  3. openresty nginx 安装过程记录

    转载请注明原始地址 http://www.cnblogs.com/dongxiao-yang/p/4877799.html 一 :系统版本 1 cat /etc/issue: CentOS relea ...

  4. lua 5.3.5 安装/初体验

    安装 官网http://www.lua.org/start.html 参考  https://blog.csdn.net/qq_23954569/article/details/70879672 cd ...

  5. luarocks 包管理工具

    安装方式:wget http://luarocks.org/releases/luarocks-2.2.2.tar.gz tar zxvf luarocks-2.2.2.tar.gz cd luaro ...

  6. lua第三方库

    一.Lua 包管理工具 1.LuaRocks luarocks 是Lua常用的包管理工具(还有一个是LuaDist),其安装方式请参考官网:https://luarocks.org/#quick-st ...

  7. lua redis接口 (在ubuntu16.04 环境下配置lua-redis开发环境)

    目前成功的lua版本是5.1, 根据网络上的资料显示 lua5.1能够支持 lua-socket 安装lua及相关软件: #安装lua5. #安装lua-socketxiangg sudo apt i ...

  8. 安装 LuaSocket

    如果你安装有 Lua 模块的安装和部署工具 -- LuaRocks,那么一条指令就能安装部署好 LuaSocket: luarocks install luasocket  

  9. luasocket编译安装遇到的坑

    由于需要获得本机的IP地址,所以需要 : local socket = require('socket') local server_hostname = socket.dns.gethostname ...

随机推荐

  1. ios8及以前的特性

    目前最新系统为ios8.以下为历代系统的回顾: iOS 1 关键词:iPhone的诞生 也许放在现在来看,当时的情景很难想象.当第一代iPhone正式发布时,在某些功能和方面其实是要远远落后于当时的竞 ...

  2. NSString NSCFString区别

    NSString 是 NSCFString的父类 在于NSString是个class cluster,一个类簇.什么是一个类簇?简单的来说,NSString是个“工厂类”,然后它在外层提供了很多方法接 ...

  3. 简明Vim练级攻略

    原文:酷壳网 vim的学习曲线相当的大(参看各种文本编辑器的学习曲线),所以,如果你一开始看到的是一大堆VIM的命令分类,你一定会对这个编辑器失去兴趣的.下面的文章翻译自<Learn Vim P ...

  4. JS获取IP

    新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js新浪多地域测试方法:http://int.dpool.s ...

  5. prototype/constructor/__proto__之constructor。

    1.constructor的字面意思就是构造.它是对象的一个属性,它对应的值是该对象的“构造者” //一.构造函数实例化的对象的constructor function Cmf(n,m){ this. ...

  6. js事件处理 —— 详解

    对于JS事件处理分为四部分: 1.html事件处理程序 直接添加到HTML结构中 解析:用html处理程序可以直接在button元素里直接调用,但是维护性不是很方便 <!DOCTYPE html ...

  7. E题 - A+B for Input-Output Practice (IV)

      Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description You ...

  8. Josephus2

    约瑟夫问题升级问题 编号为1~N的N个人按顺时针方向围坐一圈,每个人持有一个密码(正整数,可以自由输入),开始人选一个正整数作为报数上限值M,从第一个人按顺时针方向自1开始顺序报数,报道M是停止报数. ...

  9. 发送邮件(E-mail)方法整理合集

    在IOS开发中,有时候我们会需要用到邮件发送的功能.比如,接收用户反馈和程序崩溃通知等等.其实这个功能是很常用的,因为我目前就有发送邮件的开发需求,所以顺便整理下IOS发送邮件的方法. IOS原生自带 ...

  10. ExtJs + Struts2 + JSON

    最近一直都在看EXTJS的东西,然后自己实践了下,界面倒是蛮漂亮的,但是一旦涉及到与服务器端进行数据互动麻烦就出来了,本来下了个例子确发现是 用DWR的,觉得我既然用了STRUTS2作为MVC的框架, ...