Lua无法加载VC++;动态链接库
我已经使用Visual Studio C/C++工具链将我的litertools项目编译为.dll,它正确地导出了Lua无法加载VC++;动态链接库,c,visual-c++,dll,lua,C,Visual C++,Dll,Lua,我已经使用Visual Studio C/C++工具链将我的litertools项目编译为.dll,它正确地导出了lua\u 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 fo
lua\u 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
当我设置configurepackage.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。我发现通过使用以下命令找不到依赖项:
将单元测试移动到单独的项目中,并更正解决方案设置