我用VS19生成了一個動態庫,這個動態庫的源代碼如下:
#include <iostream>
extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}
static int retStr(lua_State* L)
{
lua_pushstring(L, "這是dll的回傳字串");
return 1;
}
static const luaL_Reg util[] = {
{"getStr", retStr},
{NULL, NULL}
};
extern "C" __declspec(dllexport)
int luaopen_luacalldll(lua_State * L) {
luaL_newlib(L, util);
return 1;
}
生成這個動態庫之后,我在它的同目錄下做了一個lua檔案:

lua檔案代碼如下:
local obj = require("luacalldll")
print(obj.getStr())
可是我無法運行這個lua檔案,報錯圖下圖:

請問我哪里出了問題,為何我的dll都生成了,還是不能呼叫它?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/275954.html
