2014-10-12 68 views
0

我編我的litertools使用Visual Studio C/C++工具鏈項目作爲一個.dll並正確導出lua_openlitertools功能:Lua中無法加載VC++ DLL

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 

當我設置配置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 ? 

尋找到它,我調試通過電話要求(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。

回答