Google protocol Buffer Use notes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.