gpt4 book ai didi

c - Lua无法加载VC++ dll

转载 作者:行者123 更新时间:2023-11-30 17:27:40 24 4
gpt4 key购买 nike

我已使用 Visual Studio C/C++ 工具链将我的 litertools 项目编译为 .dll,并且它正确导出 lua_openlitertools 函数:

PS> dumpbin /exports .\bin\lib\litertools.dll
Microsoft (R) COFF/PE Dumper Version 14.00.22013.1

Dump of file .\bin\lib\litertools.dll

Section contains the following exports for litertools.dll

00000000 characteristics
5439D35E time date stamp Sun Oct 12 12:03:26 2014
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name

1 0 000227AD luaopen_litertools = @ILT+1960(_luaopen_litertools)
Summary

1000 .data
2000 .idata
6000 .rdata
2000 .reloc
1000 .rsrc
44000 .text
21000 .textbss

当我设置configure package.cpath然后通过执行以下操作需要litertools dll时:

CMD> lua -e "package.cpath=\".\\bin\\lib\\?.dll\"; require(\"litertools\")"

我收到以下错误

lua: error loading module 'litertools' from file '.\bin\lib\litertools.dll':
The specified module could not be found.

stack traceback:
[C]: in ?
[C]: in function 'require'
(command line):1: in main chunk
[C]: in ?

查看了一下,我通过 require (loadlib.c) 调试了调用,并到达这里:

static void *ll_load (lua_State *L, const char *path, int seeglb) {
HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS);
(void)(seeglb); /* not used: symbols are 'global' by default */
if (lib == NULL) pusherror(L);
return lib;
}

LoadLibraryExA的调用返回NULL。我不确定为什么会发生这种情况,尽管我已经使用 mingw-gcc 编译了相同的库并且能够需要该 dll。

最佳答案

我发现通过使用没有找到依赖项:

http://www.dependencywalker.com/ enter image description here

将单元测试移至单独的项目中并更正解决方案设置。

关于c - Lua无法加载VC++ dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26320981/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com