body
{
font-family: 微软雅黑;
font-size: 11pt;
line-height: 1.5;
}
html, body
{
color: #000000;
background-color: #C2E7C7;
}
h1 {
font-size:1.5em;
font-weight:bold;
}
h2 {
font-size:1.4em;
font-weight:bold;
}
h3 {
font-size:1.3em;
font-weight:bold;
}
h4 {
font-size:1.2em;
font-weight:bold;
}
h5 {
font-size:1.1em;
font-weight:bold;
}
h6 {
font-size:1.0em;
font-weight:bold;
}
img {
border:0;
max-width: 100%;
height: auto !important;
}
blockquote {
margin-top:0px;
margin-bottom:0px;
}
table {
border-collapse:collapse;
border:1px solid #bbbbbb;
}
td {
border-collapse:collapse;
border:1px solid #bbbbbb;
}
1 下载Lua 源码: http://www.lua.org/ftp/
2 编译,编译有两种方式. 1 用vs 编译 2 用vs 命令行编译
用vs编译:(我没能理解)
http://www.cnblogs.com/cydonia/archive/2013/02/04/2892051.html
用命令行编译 :(比较简单)
http://blog.csdn.net/zjg555543/article/details/11814563
我在网上找的, 新建一个myLua.bat 在Lua 目录下. 在vs 命令行下运行就好了.
内容如下:
cd src
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
cd ..
cd src
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL lua.c
link /out:lua.exe lua.obj lua52.lib
cd ..
cd src
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL lua.c luac.c
link /out:lua.exe lua.obj lua52.lib
del lua.obj
link /out:luac.exe l*.obj
cd ..
后来我又改了一下: (把编译好的文件放到 lib 目录下,这个就已经够用了)
if exist lib rd lib /q /s
md lib
cd lib
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
link /LIB /out:lua52_s.lib l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/lua.c
link /out:lua.exe lua.obj lua52.lib
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/lua.c ../src/luac.c
link /out:lua.exe lua.obj lua52.lib
del lua.obj
link /out:luac.exe l*.obj
cd ..
exit
包括各种静态库和动态库
if exist lib rd lib /q /s
md lib
cd lib
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
link /LIB /out:lua52_s.lib l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL /MD ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52_md.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL /MDd ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52_mdd.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL /MT ../src/l*.c
del lua.obj luac.obj
link /LIB /out:lua52_mt_s.lib l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL /MTd ../src/l*.c
del lua.obj luac.obj
link /LIB /out:lua52_mtd_s.lib l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/lua.c
link /out:lua.exe lua.obj lua52.lib
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/l*.c
del lua.obj luac.obj
link /DLL /out:lua52.dll l*.obj
cl /O2 /W3 /c /DLUA_BUILD_AS_DLL ../src/lua.c ../src/luac.c
link /out:lua.exe lua.obj lua52.lib
del lua.obj
link /out:luac.exe l*.obj
cd ..
exit
------------------------------
附:测试lua
在Test中添加一个cpp文件
#include<iostream>
using namespace std;
#include<lua.hpp>
int main()
{
lua_State *l = luaL_newstate();
luaL_openlibs(l);
luaL_dofile(l, "main.lua");
lua_close(l);
system("pause");
return 0;
}
ADD 一个lua脚本
1 print("hello world");