lua 5.3.5 + luasocket 3.0-rc1 + luasec 0.8 : 具有多个luaopen_xxx
lua 5.3.5 + luasocket 3.0-rc1 + luasec 0.8 : WIN32 DLL with multiple luaopen_xxx_xxx exported function names
我在Windows 7 64位计算机上使用Embarcadero C++Builder 10.1 32位。我正在使用 Embarcadero IDE 的 CB10.1 32 位免费版本编译所有内容。我已经将lua 5.3.5编译为dll。然后我将lua.c编译成DOS可执行文件lua.exe(使用lua dll),它似乎运行正常。我将luasocket 3.0rc1编译为2 dll(socket和mime)。
luasocket脚本(ltn12.lua,mbox.lua,mime.lua和socket.lua)放在"lua"文件夹中。其余的luasocket脚本('ftp.lua','headers.lua','http.lua','smtp.lua','tp.lua'和'url.lua')放在'socket文件夹'中。"套接字.dll"更名为"核心.dll"并放置在"套接字"文件夹中。"MIME.dll"更名为"Core.dll"并放置在"MIME"文件夹中。
我使用我编译的lua.c + dll从DOS提示符运行lua。我可以正确地发出http/ftp/smtp请求。Lua似乎能够正确找到所有的Luasocket核心.dll和*.lua脚本。
但是当我请求一个使用 https 的网页时,当 lua 尝试加载"https.lua"时,会出现一个模块未找到错误。
所以我正在尝试编译和安装 luaSec 0.8 和 OpenSSL 1.0.2s。
我想将luaSec编译为WIN32 dll。我能够做到这一点。我根据需要使用"选项.lua创建了一个新的"选项.h"。使用 DLL 依赖程序(依赖 Walker 2.2),我看到从 dll 导出的四个函数:
luaopen_ssl_config
luaopen_ssl_context
luaopen_ssl_core
luaopen_ssl_x509
dll 被重命名为 core.dll 并放置在"ssl"文件夹中。luaSec发行版中的"https.lua"被放置在"ssl"文件夹中,"ssl.lua"放在"lua"文件夹中。
然后:
我的 lua 脚本需要 luasocket:
local url = require("socket.url")
local http = require("socket.http")
luasocket(在http.lua中)需要luaSec:
local https = assert(require("ssl.https"), 'LuaSocket: LuaSec not found')
然后luaSec(https.lua)需要:
local ssl = require("ssl")
然后luaSec(在ssl.lua中)需要:
local core = require("ssl.core")
local context = require("ssl.context")
local x509 = require("ssl.x509")
local config = require("ssl.config")
"ssl.core"的第一个要求有效。"ssl.context"的第二个要求失败,并显示"找不到模块'ssl.context'"。
如果我将luaSec编译成四个dll(核心.dll,上下文.dll,x509.dll和config.dll),使得每个dll只有一个导出的函数并且函数名称与require语句匹配,https请求就可以工作。
我不清楚lua如何看待"核心.dll"内部的luaopen_ssl_x509,luaopen_ssl_context和luaopen_ssl_config。也许 lua require() 函数只是不支持每个 dll 导出多个函数。
我在任何地方都找不到任何指导。
> 正如@siffiejoe建议的那样,不要将 DLL 放入sslcore.dll
中,而是将其作为ssl.dll
提供。第一个require
调用是偶然的,因为当你需要ssl.core
时,Lua 将其映射到sslcore
(作为尝试之一),这会将package.cpath
变量中的掩码映射到....sslcore.dll
....?.dll
然后在其中查找并调用luaopen_ssl_core
。对于其他三个调用,这将中断。要解决此问题,只需将其作为 ssl.dll 提供即可。
- 在 vscode for c++ 中使用 sqlite3(未定义对 'xxx' 的引用)(我使用了 -lsqlite3)
- Eclipse/CDT_C++给出"语义错误_"类型XXX无法解决"。项目运行
- 如何正确转发声明结构"using XXX"?
- 链接器错误:在包含 .so lib 后未定义对 xxx 的引用
- 我不断收到对项目"xxx"的错误未定义引用
- 如何计算字符串 c++ 中的"xxx"数?
- pybind11:属性错误:尝试从 py 文件运行函数时,模块'XXX'没有属性'YYY'
- 将硬盘驱动器上的 BIT XXX 从 0 更改为 1
- lnk1114无法覆盖原始文件"xxx.lib",错误代码32
- C++ #include<XXX.h>相当于 Python 导入的 XXX 作为 X
- 在模板元编程中使用"struct xxx<>::val"导致错误
- 如何使用 /dev/xxx 路径中的C++获取 Ubuntu 中设备的 USB VID、PID 和序列号
- 检测到"运行时库"的不匹配LNK2038:值"MT_StaticRelease"与 xxx.obj 中的值"MTd_StaticDebug"不匹配
- Qt-creator 错误: C1083: 无法打开包含文件: 'xxx.h': 没有这样的文件或目录
- "passing const XXX as this disregards qualifiers"解释 ?
- 错误假设在GCC上从过载函数中键入XXX
- 错误:将'xxx'作为'xxx'丢弃限定符的参数传递'this' [-允许]
- 有什么区别:在命名空间 yyy 外部和内部使用 namespae xxx?
- 德尔福仿制药:E2037:'XXX'声明与以前的声明不同
- 如何避免int(xxx)_t之间的重叠,并使我的代码正确