Use VC to compile the Lua source code and generate the Lua interpreter and compiler.
1. Go to the web site to download the source code http://www.lua.org/download.html 2. Install a VC ++, I use vc6.0 3. Next we start to compile the source code, we need to compile:
- A static library
- One dynamic library
- A Lua interpreter
- A Lua Compiler
Create a static library project
- Open VC --> file --> (click) create -- (select in the pop-up box) project --> (Win32 static library)
- Create an empty project
- Project name: lualib
- Add all the source code in Lua and remove the Lua. C and luac. c files.
- Compile and generate a static library ending with lualib. Lib (used later)
Create a dynamic job Library Project
- Open VC --> file --> (click) create -- (select in the pop-up box) project --> (Win32 dynamic-Link Library)
- Create an empty project
- Project name: luadll
- Add all the source code in Lua and remove the Lua. C and luac. c files.
- Compile and generate a static library ending with luadll. dll (used later)
Create a console Project (generate Interpreter)
- Open VC --> file --> (click) create -- (select in the pop-up box) project --> (Win32 console application)
- Create an empty project
- Project name: luainterpreter
- Add only Lua. c
- Click project ---> Settings --- link --> category --- (click drop-down box) --- enter --- category/module library to add the above static library name lualib. Lib
- In order to find the added static library (lualib. Lib) during compilation, put it in your project directory, that is, the same folder as *. DSP. In this way, the compiler will find this library here.
- Compile this sample to generate a luainterpreter.exe file. This executable file can run your Lua script.
- Then, put the generated luadll.dllfile and luainterpreter.exe file in the same directory.
- Open a window to access the directory where your luainterpreter.exe file is located.
- Enter luainterpreter.exe test. Lua in the command line.
- You can execute the test. Lua script.
Now write the following code in a text editor and save it as test. Lua.
function fact(n)if n == 0 then return 1else return n * fact(n - 1)endendprint("Enter a number:")a = io.read("*number")print(fact(a))
Create a console Project (generate compiler)
- Open VC --> file --> (click) create -- (select in the pop-up box) project --> (Win32 console application)
- Create an empty project
- Project name: luacompile
- Add only luac. c
- Click project ---> Settings --- link --> category --- (click drop-down box) --- enter --- category/module library to add the above static library name lualib. Lib
- In order to find the added static library (lualib. Lib) during compilation, put it in your project directory, that is, the same folder as *. DSP. In this way, the compiler will find this library here.
- Compile this sample to generate a luacompile.exe file. This compiled file can compile your Lua script.
Link: http://www.cnblogs.com/activity-life/p/3583536.html
In addition, the differences between dynamic library and static library can be referred to: http://www.cnblogs.com/skynet/p/3372855.html
Use VC to compile the Lua source code and generate the Lua interpreter and compiler.