xLua icon indicating copy to clipboard operation
xLua copied to clipboard

lua里边可以正常加载dll库,xlua里边加载不了,有什么解决办法吗?

Open ChuYiQiu opened this issue 5 years ago • 13 comments

local func = package.loadlib(dll_path, "luaopen_luacom")
print("module init func", type(func))```
这段代码我在lua里边运行 type(func)是function
在xlua里边运行是nil

ChuYiQiu avatar Sep 14 '20 06:09 ChuYiQiu

你加载dll干嘛呢?ios又不允许。

chexiongsheng avatar Sep 14 '20 10:09 chexiongsheng

ios有调用加载dll的api会被拒,所以xlua删了

chexiongsheng avatar Sep 14 '20 10:09 chexiongsheng

我在pc端用xlua,dll是必须的呀!

ChuYiQiu avatar Sep 14 '20 11:09 ChuYiQiu

我在pc上用xlua,加载dll是必须的,这个有办法解决吗?

------------------ 原始邮件 ------------------ 发件人: "chexiongsheng"<[email protected]>; 发送时间: 2020年9月14日(星期一) 晚上6:59 收件人: "Tencent/xLua"<[email protected]>; 抄送: "走日兰"<[email protected]>; "Author"<[email protected]>; 主题: Re: [Tencent/xLua] lua里边可以正常加载dll库,xlua里边加载不了,有什么解决办法吗? (#808)

ios有调用加载dll的api会被拒,所以xlua删了

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ChuYiQiu avatar Sep 14 '20 11:09 ChuYiQiu

那你加LUA_USE_DLOPEN宏,然后重编译下

chexiongsheng avatar Sep 14 '20 11:09 chexiongsheng

好的,谢谢。

------------------ 原始邮件 ------------------ 发件人: "chexiongsheng"<[email protected]>; 发送时间: 2020年9月14日(星期一) 晚上7:20 收件人: "Tencent/xLua"<[email protected]>; 抄送: "走日兰"<[email protected]>; "Author"<[email protected]>; 主题: Re: [Tencent/xLua] lua里边可以正常加载dll库,xlua里边加载不了,有什么解决办法吗? (#808)

那你加LUA_USE_DLOPEN宏,然后重编译下

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ChuYiQiu avatar Sep 14 '20 11:09 ChuYiQiu

------------------ 原始邮件 ------------------ 发件人: "Tencent/xLua" <[email protected]>; 发送时间: 2020年9月14日(星期一) 晚上7:20 收件人: "Tencent/xLua"<[email protected]>; 抄送: "走日兰"<[email protected]>;"Author"<[email protected]>; 主题: Re: [Tencent/xLua] lua里边可以正常加载dll库,xlua里边加载不了,有什么解决办法吗? (#808)

那你加LUA_USE_DLOPEN宏,然后重编译下

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

加 LUA_USE_DLOPEN 没什么用呀,LUA_DL_DLL也不起作用

何以教我?

ChuYiQiu avatar Sep 14 '20 12:09 ChuYiQiu

那你加LUA_USE_DLOPEN宏,然后重编译下

你好,我是在别人的软件上做插件,这个软件运行在windows平台采用的是c#+xlua,xlua.dll我已经替换,但是我在脚本里边loadlib会失效。他们作者说没有修改过xlua,这个我就无法理解,你能帮忙解释下在什么情况下会无效吗?

local path = "D:\Projects\Legend\new\NewLongFGUIProject\plugins\add-popup\lib\excel\bin\luacom.dll" local func = package.loadlib(path, "luaopen_luacom") fprint("module init func" .. type(func)) --require("luacom") fprint(type(luacom))

两个打印的类型都是nil,require会报如下错误 [09:52:38] Failed to load plugin at 'D:\Projects\Legend\new\NewLongFGUIProject\plugins\add-popup'

at XLua.LuaEnv.ThrowExceptionFromError (System.Int32 oldTop) [0x00000] in <00000000000000000000000000000000>:0 at XLua.LuaEnv.DoString (System.String chunk, System.String chunkName, XLua.LuaTable env) [0x00000] in <00000000000000000000000000000000>:0 at FairyEditor.PluginManager.Load (System.String pluginFolder) [0x00000] in <00000000000000000000000000000000>:0 at FairyEditor.PluginManager.Load () [0x00000] in <00000000000000000000000000000000>:0 at System.Threading.ThreadStart.Invoke () [0x00000] in <00000000000000000000000000000000>:0 ... 我这个还有方法加载使用dll吗?

ChuYiQiu avatar Sep 18 '20 01:09 ChuYiQiu

我看了下window下xlua还是保留了dll加载的能力的。 会不会是位数不匹配呢? 比如你的xlua.dll是64位,你加载的dll是32位。 package.loadlib的第二个返回值是错误信息,你可以打印看看。

chexiongsheng avatar Sep 18 '20 02:09 chexiongsheng

好的,谢谢,错误信息是"%1 不是有效的 Win32 应用程序。", 估计就是你说的问题。

------------------ 原始邮件 ------------------ 发件人: "chexiongsheng"<[email protected]>; 发送时间: 2020年9月18日(星期五) 上午10:21 收件人: "Tencent/xLua"<[email protected]>; 抄送: "走日兰"<[email protected]>; "Author"<[email protected]>; 主题: Re: [Tencent/xLua] lua里边可以正常加载dll库,xlua里边加载不了,有什么解决办法吗? (#808)

我看了下window下xlua还是保留了dll加载的能力的。 会不会是位数不匹配呢? 比如你的xlua.dll是64位,你加载的dll是32位。 package.loadlib的第二个返回值是错误信息,你可以打印看看。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ChuYiQiu avatar Sep 18 '20 03:09 ChuYiQiu

还有后续吗?我这边也遇到这个问题,分别编译了x86和x64两个版本的dll,分别在luajit-2.1.0b3的32位和64位里单独调用都能够成功调用,但放在xlua环境下,就是无法加载。明明xlua用的是luajit-2.1.0b3,为何无法加载呢?

broyden avatar Mar 23 '21 16:03 broyden

抱歉,我这边不是用xlua开发,也没有深入研究,猜测是xlua不支持加载dll吧!你再看看吧!

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年3月24日(星期三) 凌晨0:42 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [Tencent/xLua] lua里边可以正常加载dll库,xlua里边加载不了,有什么解决办法吗? (#808)

还有后续吗?我这边也遇到这个问题,分别编译了x86和x64两个版本的dll,分别在luajit-2.1.0b3的32位和64位里单独调用都能够成功调用,但放在xlua环境下,就是无法加载。明明xlua用的是luajit-2.1.0b3,为何无法加载呢?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ChuYiQiu avatar Apr 18 '21 02:04 ChuYiQiu

还有后续吗?我这边也遇到这个问题,分别编译了x86和x64两个版本的dll,分别在luajit-2.1.0b3的32位和64位里单独调用都能够成功调用,但放在xlua环境下,就是无法加载。明明xlua用的是luajit-2.1.0b3,为何无法加载呢?

这个问题我也遇到了,请问您解决了吗?我按照上面说的LUA_USE_DLOPEN宏,然后重编译xlua,还是没法加载dll

ccwccwccw avatar Dec 23 '22 19:12 ccwccwccw