LuaSocket socket/core.dll 需要的位置? [英] LuaSocket socket/core.dll required location?
问题描述
当我使用
local socket = require("socket.core")
它工作正常,该dll位于"dir/socket/core.dll",但是当我移动dll时说
It works fine, the dll is located at "dir/socket/core.dll" but when I move the dll to say
"dir/folder/core.dll"并使用
"dir/folder/core.dll" and use
local socket = require("folder.core.")
它返回找到的内容,但是在folder.core中找不到特定的模块.
It returns that it was found however it could not find the specific module in folder.core.
如何在socket.core要求之外使用Luasocket?
How do I use Luasocket outside of it's socket.core requirements?
谢谢!
推荐答案
如果要 require("socket.core")
,则共享库(dll)必须具有一个称为的导出函数luaopen_socket_core(LuaSocket库具有).因此,始终需要将其称为 require("socket.core")
.
If you want to require("socket.core")
, the shared library (dll) has to have an exported function called luaopen_socket_core (which the LuaSocket library has). Thus, it always needs to be called as require("socket.core")
.
如果要将DLL移至其他文件夹,则必须修改 package.cpath
,其中包含将要检查的文件模式.
If you want to move the DLL into some other folder, you have to modify package.cpath
, which contains the file patterns which will be checked.
假设您要将LuaSocket二进制文件移至 folder
.您必须在调用 require
之前将二进制文件放入 folder/socket/core.dll
并修改 package.cpath
:
Let's say that you want to move the LuaSocket binary to folder
. You have to place the binary in folder/socket/core.dll
and modify package.cpath
prior to calling require
:
package.cpath = package.cpath .. ';folder/?.dll'
local socket = require('socket.core')
?
表示传递给 require
的名称,该名称已转换为文件路径:.->/
,即 socket.core->套接字/核心
.
?
represents the name passed to require
translated to file paths: . -> /
, i.e. socket.core -> socket/core
.
这篇关于LuaSocket socket/core.dll 需要的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!