luasocket编译安装遇到的坑

时间:2022-08-26 21:28:08

由于需要获得本机的IP地址,所以需要 :

local socket = require('socket')
local server_hostname = socket.dns.gethostname()
local server_ip = socket.dns.toip(server_hostname)

需要下载源码编译:luasocket-2.0.2.tar.gz

- 解压好之后首先修改config文件来制定安装的路径,修改涉及的三个地方:

# 由于是先安装的openresty-1.13.6.1:/opt/soft/openresty/
LUAINC=-I/opt/soft/openresty/luajit/include/luajit-2.1/
INSTALL_TOP_SHARE=/opt/soft/openresty/luajit/share/lua/5.1
INSTALL_TOP_LIB=/opt/soft/openresty/luajit/lib/lua/5.1

- 编译安装

make
make install
 cd src; make all
make[1]: Entering directory `/data/tools/luasocket-2.0.2/src'
gcc -I/opt/soft/openresty/luajit/include/luajit-2.1/ -DLUASOCKET_DEBUG -pedantic -Wall -O2 -fpic -c -o luasocket.o luasocket.c
In file included from luasocket.c:31:0:
auxiliar.h:38:61: error: unknown type name ‘luaL_reg’
void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func);
^
luasocket.c:50:1: error: unknown type name ‘luaL_reg’
static const luaL_reg mod[] = {
^
luasocket.c:51:5: warning: braces around scalar initializer [enabled by default]
{"auxiliar", auxiliar_open},
^
luasocket.c:51:5: warning: (near initialization for ‘mod[0]’) [enabled by default]
luasocket.c:51:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:51:5: warning: (near initialization for ‘mod[0]’) [enabled by default]
luasocket.c:51:5: error: initializer element is not computable at load time
luasocket.c:51:5: error: (near initialization for ‘mod[0]’)
luasocket.c:51:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:51:5: warning: (near initialization for ‘mod[0]’) [enabled by default]
luasocket.c:52:5: warning: braces around scalar initializer [enabled by default]
{"except", except_open},
^
luasocket.c:52:5: warning: (near initialization for ‘mod[1]’) [enabled by default]
luasocket.c:52:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:52:5: warning: (near initialization for ‘mod[1]’) [enabled by default]
luasocket.c:52:5: error: initializer element is not computable at load time
luasocket.c:52:5: error: (near initialization for ‘mod[1]’)
luasocket.c:52:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:52:5: warning: (near initialization for ‘mod[1]’) [enabled by default]
luasocket.c:53:5: warning: braces around scalar initializer [enabled by default]
{"timeout", timeout_open},
^
luasocket.c:53:5: warning: (near initialization for ‘mod[2]’) [enabled by default]
luasocket.c:53:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:53:5: warning: (near initialization for ‘mod[2]’) [enabled by default]
luasocket.c:53:5: error: initializer element is not computable at load time
luasocket.c:53:5: error: (near initialization for ‘mod[2]’)
luasocket.c:53:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:53:5: warning: (near initialization for ‘mod[2]’) [enabled by default]
luasocket.c:54:5: warning: braces around scalar initializer [enabled by default]
{"buffer", buffer_open},
^
luasocket.c:54:5: warning: (near initialization for ‘mod[3]’) [enabled by default]
luasocket.c:54:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:54:5: warning: (near initialization for ‘mod[3]’) [enabled by default]
luasocket.c:54:5: error: initializer element is not computable at load time
luasocket.c:54:5: error: (near initialization for ‘mod[3]’)
luasocket.c:54:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:54:5: warning: (near initialization for ‘mod[3]’) [enabled by default]
luasocket.c:55:5: warning: braces around scalar initializer [enabled by default]
{"inet", inet_open},
^
luasocket.c:55:5: warning: (near initialization for ‘mod[4]’) [enabled by default]
luasocket.c:55:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:55:5: warning: (near initialization for ‘mod[4]’) [enabled by default]
luasocket.c:55:5: error: initializer element is not computable at load time
luasocket.c:55:5: error: (near initialization for ‘mod[4]’)
luasocket.c:55:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:55:5: warning: (near initialization for ‘mod[4]’) [enabled by default]
luasocket.c:56:5: warning: braces around scalar initializer [enabled by default]
{"tcp", tcp_open},
^
luasocket.c:56:5: warning: (near initialization for ‘mod[5]’) [enabled by default]
luasocket.c:56:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:56:5: warning: (near initialization for ‘mod[5]’) [enabled by default]
luasocket.c:56:5: error: initializer element is not computable at load time
luasocket.c:56:5: error: (near initialization for ‘mod[5]’)
luasocket.c:56:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:56:5: warning: (near initialization for ‘mod[5]’) [enabled by default]
luasocket.c:57:5: warning: braces around scalar initializer [enabled by default]
{"udp", udp_open},
^
luasocket.c:57:5: warning: (near initialization for ‘mod[6]’) [enabled by default]
luasocket.c:57:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:57:5: warning: (near initialization for ‘mod[6]’) [enabled by default]
luasocket.c:57:5: error: initializer element is not computable at load time
luasocket.c:57:5: error: (near initialization for ‘mod[6]’)
luasocket.c:57:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:57:5: warning: (near initialization for ‘mod[6]’) [enabled by default]
luasocket.c:58:5: warning: braces around scalar initializer [enabled by default]
{"select", select_open},
^
luasocket.c:58:5: warning: (near initialization for ‘mod[7]’) [enabled by default]
luasocket.c:58:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:58:5: warning: (near initialization for ‘mod[7]’) [enabled by default]
luasocket.c:58:5: error: initializer element is not computable at load time
luasocket.c:58:5: error: (near initialization for ‘mod[7]’)
luasocket.c:58:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:58:5: warning: (near initialization for ‘mod[7]’) [enabled by default]
luasocket.c:59:5: warning: braces around scalar initializer [enabled by default]
{NULL, NULL}
^
luasocket.c:59:5: warning: (near initialization for ‘mod[8]’) [enabled by default]
luasocket.c:59:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:59:5: warning: (near initialization for ‘mod[8]’) [enabled by default]
luasocket.c:59:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:59:5: warning: (near initialization for ‘mod[8]’) [enabled by default]
luasocket.c:62:1: error: unknown type name ‘luaL_reg’
static luaL_reg func[] = {
^
luasocket.c:63:5: warning: braces around scalar initializer [enabled by default]
{"skip", global_skip},
^
luasocket.c:63:5: warning: (near initialization for ‘func[0]’) [enabled by default]
luasocket.c:63:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:63:5: warning: (near initialization for ‘func[0]’) [enabled by default]
luasocket.c:63:5: error: initializer element is not computable at load time
luasocket.c:63:5: error: (near initialization for ‘func[0]’)
luasocket.c:63:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:63:5: warning: (near initialization for ‘func[0]’) [enabled by default]
luasocket.c:64:5: warning: braces around scalar initializer [enabled by default]
{"__unload", global_unload},
^
luasocket.c:64:5: warning: (near initialization for ‘func[1]’) [enabled by default]
luasocket.c:64:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:64:5: warning: (near initialization for ‘func[1]’) [enabled by default]
luasocket.c:64:5: error: initializer element is not computable at load time
luasocket.c:64:5: error: (near initialization for ‘func[1]’)
luasocket.c:64:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:64:5: warning: (near initialization for ‘func[1]’) [enabled by default]
luasocket.c:65:5: warning: braces around scalar initializer [enabled by default]
{NULL, NULL}
^
luasocket.c:65:5: warning: (near initialization for ‘func[2]’) [enabled by default]
luasocket.c:65:5: warning: initialization makes integer from pointer without a cast [enabled by default]
luasocket.c:65:5: warning: (near initialization for ‘func[2]’) [enabled by default]
luasocket.c:65:5: warning: excess elements in scalar initializer [enabled by default]
luasocket.c:65:5: warning: (near initialization for ‘func[2]’) [enabled by default]
luasocket.c: In function ‘base_open’:
luasocket.c:92:9: warning: passing argument 3 of ‘luaL_openlib’ from incompatible pointer type [enabled by default]
luaL_openlib(L, "socket", func, 0);
^
In file included from luasocket.c:21:0:
/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h:26:18: note: expected ‘const struct luaL_Reg *’ but argument is of type ‘int *’
LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
^
luasocket.c: In function ‘luaopen_socket_core’:
luasocket.c:116:23: error: request for member ‘name’ in something not a structure or union
for (i = 0; mod[i].name; i++) mod[i].func(L);
^
luasocket.c:116:41: error: request for member ‘func’ in something not a structure or union
for (i = 0; mod[i].name; i++) mod[i].func(L);
^
luasocket.c:116:46: error: called object is not a function or function pointer
for (i = 0; mod[i].name; i++) mod[i].func(L);
^
luasocket.c:116:35: warning: statement with no effect [-Wunused-value]
for (i = 0; mod[i].name; i++) mod[i].func(L);
^
make[1]: *** [luasocket.o] Error 1
make[1]: Leaving directory `/data/tools/luasocket-2.0.2/src'
make: *** [all] Error 2

make时候报错

 root@fbprophet-10.153.169.67[17:29:32]$ grep -r -i luaL_reg /opt/soft/openresty/ |grep -v Binary
/opt/soft/openresty/resty.index: section 127415 127764 lual_reg
/opt/soft/openresty/resty.index: section 127764 128541 lual_register
/opt/soft/openresty/resty.index: section 195477 195545 function lual_openlib was replaced by lual_register.
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod:=head2 C<luaL_Reg>
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod: typedef struct luaL_Reg {
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod: } luaL_Reg;
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod:Type for arrays of functions to be registered by C<luaL_register>.
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod:Any array of C<luaL_Reg> must end with an sentinel entry in which both
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod:=head2 C<luaL_register>
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod: void luaL_register (lua_State *L,
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod: const luaL_Reg *l);
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod:functions in the list C<l> (see C<luaL_Reg>) into the table on the top
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod:When called with a non-null C<libname>, C<luaL_register> creates a new
/opt/soft/openresty/pod/lua-5.1.5/lua-5.1.5.pod:=item * Function C<luaL_openlib> was replaced by C<luaL_register>.
/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h:typedef struct luaL_Reg {
/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h:} luaL_Reg;
/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h: const luaL_Reg *l, int nup);
/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h:LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h: const luaL_Reg *l);
/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h:LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
root@fbprophet-10.153.169.67[17:29:36]$

查找luaL_reg

/opt/soft/openresty/luajit/include/luajit-2.1/lauxlib.h 里定义的结构体名字和 luaL_reg 不一致

 typedef struct luaL_Reg {
const char *name;
lua_CFunction func;
} luaL_Reg;

然后把 luasocket-2.0.2/src 下所有luaL_reg 替换成 luaL_Reg

然后重新编译就可以了。

luasocket编译安装遇到的坑的更多相关文章

  1. openssl1&period;0在mac下的编译安装(踩坑精华)

    之前做了一次brew版本升级,然后用pip3安装的一个python命令就无法执行了(涉及到openssl库),执行就会报一个错误. ImportError: dlopen(/usr/local/Cel ...

  2. centos7编译安装redis遇坑

    编译redis时:make cc Command not found 原因分析:没有安装gcc,执行: yum install gcc 编译redis时:error: jemalloc/jemallo ...

  3. 源码编译安装 ganesha

    源码编译安装 ganesha 简介 系统环境:CentOS 7.5 ceph:luminous nfs-ganesha:v2.6 stable 安装步骤 安装依赖 首先需要安装编译会用到的公共库 1 ...

  4. Ubuntu16&period;04编译安装tensorflow,2018最新血泪踩坑之后的全面总结!绝对成功!【转】

    本文转载自:https://blog.csdn.net/pzh11001/article/details/79683133 大家好,我是 (深度学习硬件DIY总群)(719577294)群主:    ...

  5. 源码编译安装lnmp环境&lpar;nginx-1&period;14&period;2 &plus; mysql-5&period;6&period;43 &plus; php-5&period;6&period;30 &rpar;------踩了无数坑,重装了十几次服务器才会的&comma;不容易啊!

    和LAMP不同的是,LNMP中的N指的是Nginx(类似于Apache的一种web服务软件),并且php是作为一个独立服务存在的,这个服务叫做php-fpm,Nginx直接处理静态请求,动态请求会转发 ...

  6. 源码编译安装MySQL-5&period;6&sol;mysql-5&period;6&period;39------踩了无数坑,重装了十几次服务器才会的&comma;不容易啊!

    1.切换到src目录 cd /usr/local/src/ 2. 下载mysql免编译二进制包 免编译的mysql二进制包5.6源码包: wget http://mirrors.163.com/mys ...

  7. 源码编译安装Apache&sol;2&period;4&period;37-------踩了无数坑,重装了十几次服务器才会的&comma;不容易啊!

    1.先进入/usr/local/中创建三个文件夹 apr apr-util apache cd /usr/local目录 mkdir apr mkdir apr-util mkdir apache 2 ...

  8. Opencv3&period;3&lpar;Linux&rpar;编译安装至python的坑

    编译安装OpenCV绝对是一件让人发狂的事情,CMake繁多的选项,国内蛋疼的网速,实在让人无力吐槽,然而为了使用contrib包,我不得不重新编译他. OpenCV的编译 其实OpenCV编译并不是 ...

  9. 源码编译安装PHP Version 5&period;6&period;30------踩了无数坑,重装了十几次服务器才会的&comma;不容易啊!

    1 环境准备 yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel ...

随机推荐

  1. 自我提升mysql

    1.某字段更新 自增 1 update table set a=a+1 2.修改某一字段的数据类型 alter table "tablename" modify  "co ...

  2. &lbrack;原博客&rsqb; BZOJ 2725 &colon; &lbrack;Violet 6&rsqb;故乡的梦

    这个题在bzoj上好像是个权限题,想做的可以去Vani的博客下载测试数据.这里有题面. 简单叙述一下题意:给你一个n个点.m条边的带权无向图,S点和T点,询问Q次删一条给定的边的S-T最短路. 其中  ...

  3. 2014 CSDN博文大赛终于获奖名单发布

    博文大赛第二阶段(2014年7月15日-2014年8月10日)已经结束,决赛获奖名单已在8月11日出炉. 现将获奖名单发布: 移动开发 NO.1    罗升阳    Luoshengyang    S ...

  4. oracle substr功能

    substr(string dealstr, int startposition, int sublength) dealstr:截取字符串 startposition:串dealstr,起始位置0 ...

  5. Android 7&period;0 安装器安装过程分析 &lpar;com&period;android&period;packageinstaller&rpar;

    1 安装入口PackageInstallerActivity,这个类只是在安装前做准备.通过各种校验,然后弹出被安装应用的权限框,等待用户安装.具体的流程如下 1.1  求mSessionId 如果是 ...

  6. UVA - 11292 Dragon of Loowater 贪心

    贪心策略:一个直径为X的头颅,应该让雇佣费用满足大于等于X且最小的骑士来砍掉,这样才能使得花费最少. AC代码 #include <cstdio> #include <cmath&g ...

  7. Django 项目搭建&lpar;ubuntu系统&rpar;

    1 环境搭建 sudo apt-get install python3-pip 安装pip3 sudo pip3 install virtualenv 安装虚拟环境,这里展示virtualenv vi ...

  8. Git:一个简单示例

    初始状态:两个分支master/dev都只有一个文件readme.txt 待解决问题:在master分支新增文件,并且修改readme.txt文件,将上述操作同步至远程master分支,最后同步到de ...

  9. 【C&num;&sol;WPF】图像数据格式转换时,透明度丢失的问题

    问题:工作中涉及到图像的数据类型转换,经常转着转着发现,到了哪一步图像的透明度丢失了! 例如,Bitmap转BitmapImage的经典代码如下: public static BitmapImage ...

  10. DIY自己的GIS程序(1)——起航

    一个GIS系统最重要的功能是绘制图形和关联属性,这里研究二维点线面的绘制过程: 对于一个绘图系统设计,图形的绘制涉及两个重要的方面. 1.一个是绘制或者重新绘制,重绘过程出现在下面情况: a 界面初始 ...