最近才开始接触Lua,发现很对教学视频还有资料都是基于Lunix。找了好久才找到可行的编译lua的方法
准备阶段:
在lua.org上下载最新的lua
Windows上安装visual studio
实践过程
1、打开VS,new->project->other project types->blank solution->name: Lua_build->OK
2、solution explorer->右键solution:Lua_build->add new project->visual c++
->empty project->name:Lua_lib->OK
3、solution explorer->右键Lua_lib->add existing item->找到lua的src,添加所有文件(Lua.c,Luac.c除外)
4、solution explorer->右键Lua_lib->properties->configuration properties->general->
configuration type->static library
->OK
5、solution explorer->右键Lua_lib->build
6、solution explorer->右键solution:Lua_build->open folder in file explorer->debug->出现Lua-lib.lib
7、solution explorer->右键solution:Lua_build->
add new project->visual c++
->empty project->name:Lua->OK
8、添加lua.c到Lua的source files->solution explorer->右键Lua->properties->configuration properties
->linker->input->addtional dependencies->单击下拉按钮,填写Lua_lib.lib->OK
->general->addtional library directories->单击下拉按钮,填写Lua_lib.lib所在目录->OK
9、同样的方法(7,8)设置Luac(命名为Luac,添加Luac.c,其他步骤一样)
10、solution explorer->右键solution:Lua_build->build
11、Lua_lib.lib目录下生成Lua.exe,Luac.exe
运行Lua.exe,可以输入lua语句并执行
也可以用Lua.exe运行.lua文件
Luac.exe是lua的编译器,可以将.lua文件处理产生.out文件,并用Lua.exe执行
如有疑问或者习惯使用中文VS,参考http://download.youkuaiyun.com/detail/linkhai/8674255