看雲上的《Lua編程入門》,比《Lua程序設計(第2版)中文》好多了 https://www.kancloud.cn/thinkphp/lua-guide/43809 SF上的編譯Lua源碼 https://segmentfault.com/a/1190000004904799
源碼下載地址
http://www.lua.org/ftp/lua-5.3.4.tar.gz
SF的編譯腳本挺酷的,腳本寫好,確實省不少事。php
上邊基本把須要的知識點都講通了,我講一下遇到的問題,及處理thinkphp
> require "WinFeature" > for k, v in pairs(WinFeature) do >> print(k, v) >> end ShowMsgBox functon:0028AB90 >
須要改爲編程
dlltest = require "WinFeature" for k, v in pairs(dlltest) do print(k, v) end dlltest.ShowMsgBox()
2. 這段代碼須要用新版本的函數segmentfault
extern "C" __declspec(dllexport) int luaopen_WinFeature(lua_State* luaEnv) { const char* const LIBRARY_NAME = "WinFeature"; luaL_register(luaEnv, LIBRARY_NAME, luaLibs); return 1; }
修改爲ide
extern "C" __declspec(dllexport) int luaopen_WinFeature(lua_State* luaEnv) { const char* const LIBRARY_NAME = "WinFeature"; luaL_newlib(luaEnv, luaLibs); return 1; }
3. 必須使用配套的 lua.dll lua.exe lua.lib函數
一開始使用別人編譯的Lua.exe,跑Dll,會報錯:「multiple Lua VMs detected」ui