A moment to download
Google:https://developers.google.com/protocol-buffers/docs/downloads?hl=zh-cn
Github:https://github.com/google/protobuf
I am here to download version: protobuf-2.6.1.tar.gz
Two compilations
1 decompression
Unzip the above compressed package into the folder protobuf-2.6.1.
2 compiling
2.1 In protobuf-2.6.1, find Vsprojects/protobuf.sln, double-click with VS Open.
2.2 Set the compilation mode to release mode and compile Libprotobuf,libprotobuf-lite,libprotoc,protoc (right-click build).
3 Copy Library
In Vsprojects\release find Libprotobuf.lib,libprotobuf-lite.lib,libprotoc.lib and Protoc.exe, copy to C:\Windows directory.
4 Generating header files
Double-clicking the Extract_includes.bat will generate an include directory in the Vsprojects directory.
Three compiler Proto
1 Create a new Person.proto in the D:/GPB directory and edit the contents as follows:
Package Proto;message Person { Required String name = 1; Required Int32 id = 2; Optional String email = 3;}
#gpb即Google Protocol Buffer
2 generating C + + classes
In the GPB file, right-click here to open the command line and enter:
Protoc.exe Person.proto--cpp_out=.
This generates the person class under the current folder, with the following file:
Four Prote detailed
1 Key Words
The package keyword is the specified namespace
The message keyword, similar to struct in C or class in C + + and Java
2 Property Description
Required non-empty fields
Optional optional fields
Repeated represents a field that can contain 0 or more data.
3 types
Original link: http://blog.csdn.net/xufeng0991/article/details/45031211
Google protocol Buffer Use notes