Protobuf doesn’t officially have a Lua version, so netease’s app developer developed Protoc-Gen-Lua, which allows us to convert Proto files into Lua scripts for use in Lua, but since no one has been maintaining them in the end, it looks like we can only use the Proto2 version.

1, First we need to download the relevant resources

Link: Link: pan.baidu.com/s/1Khb-V7iF… Extract code: 6F0G

We need to install Python2.7

Add the installation directory to the environment variables, then open the command line console and enter the commands

If the following figure is displayed, the Python installation is successful

Download and compile Luajit 2.0.4

After downloading and decompressing, find the luajit-2.0.4 / SRC directory, which has a batch file msvcbuild.bat, which is the compilation tool for Windows systems. Find Visual Studio Tools from the Start menu – Visual Studio 201x in All Applications, open the VS201x Developer command prompt, switch to the luajit-2.0.4 / SRC directory, and run the command

Msvcbuild. bat to LuaJIT-2.0.4\ SRC directory to find lua51. DLL lua51.lib luajit.exe files, if the above compile successfully, then these three files must exist.

Download and compile protobuf-2.4.1 (I have fixed the errors, protoc.exe has been generated)

5. Run the command in the protobuf-2.4.1\python folder

python setup.py install

6. Combine files

Copy the two files, and copy some of the previous generated files (lua.exe actually changed its name, the generated files are luajit.exe).

Put the protobuf-gen-Lua in these two files

Copy it in here

7. Use, this is my own to make a test tool, the above three times corresponding to generate C++, Java, lua code, protobuf folder is the previous generation of those files stored place

Proto2c ++_lua.bat generates all the.proto files in this directory into the folder of each of the three languages in CreateCode