I feel that I have no idea about it recently. Let's take a look at the Lua source code and pass the time.
First, download and compile the Lua source code.
1. first, you need to download the Lua source code from the official website and download the Lua source code from www.lua.org. The latest version is 5.1 rc420.lua-5.1.4.tar.gz. After decompression, the directory contains the install file, this file details the compilation process in Linux, and the compilation in Visual Studio also mentions
2. Compile lualib
Create a VC ++ console project lualib, "ApplicationProgramSet "---> static library to generate the default. H ,. CPP deletion. Do not use the pre-compiled header when setting it, right-click the lualib project --> Add ---> Add existing items --> Add the following files in the src directory under the decompressed Lua source code directory (the following file lists are described in install ):
Library: lapi. c lcode. c ldebug. c ldump. c lfunc. c lgc. c llex. c
Lmem. c lobject. c lopcodes. c lparser. c lstate. c lstring. c
Ltable. c ltm. c lundump. c LVM. c lzio. c
Lauxlib. c lbaselib. c ldblib. c liolib. c lmathlib. c loslib. c
Ltablib. c lstrlib. c loadlib. c linit. c
After compilation, A lualib. Lib file is generated;
3. Compile the luac Compiler
Create a VC ++ console project luac, which is generated by default. H ,. CPP Delete, set it to not use the pre-compiled header, right-click the luac project ---> Add existing items ---> prepare;
4. Compile the Lua interpreter
Create a VC ++ console project Lua and set the default value. H ,. delete CPP, set it to do not use the pre-compiled header, right-click the Lua project ---> Add existing items ---> decompress the Lua source code directory in the src directory. h, lua.c, right-click Project dependency, and lualib,compile and generate lua.exe;
5.double-hitting lua.exe runs the Lua interpreter. You can enter LuaCodeExecuted:
6. debug Lua
In Lua. the main function in the C file has a breakpoint. If you want to run the Lua code in the interpreter, it will be broken. the loadline function of C has a breakpoint and will be called to the load_string function in lualib.