[英]How to use Lua 5.2 with luasocket 3
I am trying to compile luasocket 3 that I found on GitHub with lua 5.2 . 我正在尝试编译我在GitHub上使用lua 5.2找到的luasocket 3 。 Problem is, I'm not sure how to bind together
Lua
with luasocket
. 问题是,我不确定如何将
Lua
与luasocket
绑定在一起。 Do I need to compile luasocket
as DLL and then reference if somewhere in lua
code, or should I just call it from lua console? 我是否需要将
luasocket
编译为DLL然后引用lua
代码中的某个地方,或者我应该从lua控制台调用它?
Try installing it using luarocks . 尝试使用luarocks安装它。 If you don't have luarocks, install it following instructions on the site.
如果您没有luarocks,请按照网站上的说明进行安装。
Then download the rockspec file(luasocket-scm-0.rockspec) from luasocket repo and run 然后从luasocket repo下载rockspec文件(luasocket-scm-0.rockspec)并运行
$ luarocks install *path to the rockspec file*
If everything goes OK, you'll be able to use luasocket from Lua like this: 如果一切顺利,你将能够像Lua一样使用Lua的luasocket:
local socket = require "socket"
-- now you can use socket.xxx functions
Usually you only need to reference lua include files (there are only 4 needed: luaconf.h
, lua.h
, lualib.h
, and lauxlib.h
) and library/dll (-llua52 in your case). 通常你只需要引用lua include文件(只需要4个:
luaconf.h
, lua.h
, lualib.h
和lauxlib.h
)和library / dll(在你的例子中是-llua52)。 You don't say what compiler you are using, so it's difficult to be more specific, but I have script(s) that build luasocket with lua5.2 on Windows using mingw (and using gcc on OSX/Linux). 你没有说你正在使用什么编译器,所以很难更具体,但我有一些脚本使用mingw在Windows上使用lua5.2构建luasocket(并在OSX / Linux上使用gcc)。 For example, to compile on Windows, you can get
build-win32.sh
script and run it as: bash build-win32.sh 5.2 lua luasocket
. 例如,要在Windows上编译,您可以获取
build-win32.sh
脚本并将其运行为: bash build-win32.sh 5.2 lua luasocket
。 It will get all the files needed (using wget) and compile everything in deps/
folder; 它将获取所需的所有文件(使用wget)并编译
deps/
文件夹中的所有内容; the resulting executable and libraries will be put in ../bin
folder. 生成的可执行文件和库将放在
../bin
文件夹中。
You can also get compiled libraries from the same repository . 您还可以从同一个存储库中获取已编译的库 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.