zoukankan      html  css  js  c++  java
  • 安装luasocket 的正确姿势

    在lua中用下面这种方式使用socket,安装luasocket-2.0.2后老是报一些莫名其妙的错误。

    require("socket")
    

    下面是部分报错信息

    lua: error loading module 'socket.core' from file '/usr/local/lib/lua/5.3/socket/core.so':
    	/usr/local/lib/lua/5.3/socket/core.so: undefined symbol: luaL_checkint
    stack traceback:
    	[C]: in ?
    	[C]: in function 'require'
    	/usr/local/share/lua/5.3/socket.lua:13: in main chunk
    	[C]: in function 'require'
    	/usr/local/share/lua/5.3/socket/http.lua:11: in main chunk
    	[C]: in function 'require'
    	bb.lua:2: in main chunk
    	[C]: in ?
    

    在网上找了一篇博文写的不错,博文地址 ,但是按照博文修改源码后依然不能解决问题

    又Google了一篇文章写的更好,从根本解决上解决了问题博文地址 感谢!

    顺便在luajit-2.0.4(生产环境版本)试了一下第二种方式,在编译时会报错如下

    luasocket.c:18:17: fatal error: lua.h: No such file or directory
    compilation terminated.
    <builtin>: recipe for target 'luasocket.o' failed
    make[2]: *** [luasocket.o] Error 1
    make[2]: Leaving directory '/tmp/luasocket/src'
    makefile:359: recipe for target 'linux' failed
    make[1]: *** [linux] Error 2
    make[1]: Leaving directory '/tmp/luasocket/src'
    makefile:18: recipe for target 'linux' failed
    make: *** [linux] Error 2
    

    问题原因是make时找不到lua.h头文件,编译时自己手动指定头文件路径LUAINC=/usr/local/luajit/include/luajit-2.0,如下

    make LUAINC=/usr/local/luajit/include/luajit-2.0
    make install
    

    END

  • 相关阅读:
    【模板】常系数线性递推
    【模板】多项式除法
    【模板】多项式求逆
    codeblock的一个小问题
    IP分片浅析
    [LeetCode] Excel Sheet Column Number
    [LeetCode] Excel Sheet Column Title
    [LeetCode] Maximum Gap
    编程计算并输出1~n之间所有素数之和
    [LeetCode] Compare Version Numbers
  • 原文地址:https://www.cnblogs.com/guoew/p/10251030.html
Copyright © 2011-2022 走看看