【问题标题】:LuaSocket socket/core.dll required location?LuaSocket socket/core.dll 需要的位置?
【发布时间】:2011-09-08 19:39:06
【问题描述】:

当我使用时

local socket = require("socket.core")

它工作正常,dll位于“dir/socket/core.dll”但是当我移动dll时说

“dir/folder/core.dll”并使用

local socket = require("folder.core.")

它返回它已找到,但在 folder.core 中找不到特定模块。

我如何在它的 socket.core 要求之外使用 Luasocket?

谢谢!

【问题讨论】:

    标签: windows lua winsock require luasocket


    【解决方案1】:

    如果你想require("socket.core"),共享库(dll)必须有一个名为 luaopen_socket_core(LuaSocket 库有)的导出函数。因此,它总是需要被称为require("socket.core")

    如果要将 DLL 移动到其他文件夹,则必须修改 package.cpath,其中包含将要检查的文件模式。

    假设您要将 LuaSocket 二进制文件移动到 folder。您必须将二进制文件放入folder/socket/core.dll 并在调用require 之前修改package.cpath

    package.cpath = package.cpath .. ';folder/?.dll'
    local socket = require('socket.core')
    

    ? 表示传递给require 的名称转换为文件路径:. -> /,即socket.core -> socket/core

    【讨论】:

    • 谢谢你帮了我很多,你是一个救生员! :D
    【解决方案2】:

    我认为您只需要删除最后的点即可。

    local socket = require("folder.core")
    

    【讨论】:

      猜你喜欢
      • 2016-01-09
      • 2020-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-16
      • 2014-03-26
      • 2019-03-26
      相关资源
      最近更新 更多