Introduction and installation of Protocol buffers (protocol buffering)

Source: Internet
Author: User

Protocol buffers is a data description language developed by Google, similar to XML that can serialize structured data for data storage and communication protocols. At this stage of support

Hold three programming languages, such as C + +, JAVA, Python.

It is a binary format, much faster than using XML for data exchange. It can be used in data communication between distributed applications or in heterogeneous environments.


Http://code.google.com/intl/zh-CN/apis/protocolbuffers/docs/overview.html (Introduction)
Http://code.google.com/p/protobuf/downloads/list (Download)

Download installation
Compile installation (MINGW):
$./configure
$ make
$ make Check
$ make Install
See more: README.txt
If you are Micosoft Visual C + +, refer to Vsprojects/readme.txt.

The environment variable (PATH) under Msys is automatically set after installation in the Msys environment. The recommended directory for downloading code is the directory that will be installed.


Value types can is numbers (integer or floating-point), booleans, strings, raw bytes, or even (as in the example above) OT Her

Protocol buffer message types.
Specify optional fields, required fields, and repeated fields.

Once you ' ve defined your messages, your run the protocol buffer compiler for your application ' s language on your. Proto E to

Generate data access classes. These provide simple accessors for each field (like query () and Set_query ()) as "as", methods to

Serialize/parse the whole structure to/from raw bytes.

You can add the new fields to your message formats without breaking backwards-compatibility; Old binaries simply ignore the new field

When parsing. So if you are have a communications protocol that uses protocol buffers as it data format, you can extend your

Without has to worry about breaking existing code.

Why not just use XML?
Protocol buffers have many advantages over XML for serializing data. Protocol buffers:
are simpler
are 3 to ten times smaller
are to times faster
are less ambiguous
Generate data access classes that are easier to use programmatically.

However, protocol buffers are not always a better solution than xml–for instance, protocol buffers would good W Ay to

Model A text-based document with markup (e.g. HTML), since for you cannot easily interleave with text. In addition, the XML is

Human-readable and human-editable; Protocol buffers, at least on their native format, are not. XML is also–to some extent–self-

Describing. A protocol buffer is only meaningful if you have the message definition (the. proto file).

To builds and install your compiler, follow the instructions in the README.


FAQ:
1 An error occurred while compiling the installation (make):
In the file included from google/protobuf/compiler/command_line_interface.cc:54:
./google/protobuf/compiler/subprocess.h:80:error:extra Qualification
' Google::
Protobuf::compiler::subprocess:: ' On ' win32errormessage '
To resolve: to src/google/protobuf/compiler/subprocess.h:80 the
static string Subprocess::win32errormessage (DWORD error_code); Modified to:
static string Win32errormessage (DWORD error_code);
Reference: http://www.fourmilab.ch/fourmilog/archives/2006-05/000699.html

2 Compile-time (make) error
G++.exe:c:/msys/1.0/mingw/lib/gcc/mingw32/4.4.0/libstdc++.dll.a:no such file or directory
Solution: Open MinGW (D:\Qt\2010.05\mingw\lib\gcc\mingw32\4.4.0) of libstdc++.la (under C:\Qt\2010.05\mingw\lib\gcc\mingw32\4.4.0 ), will be one of the
# Names of this library.

library_names= ' LIBSTDC++.DLL.A '
Modified to:
# Names of this library.
library_names= ' libstdc++.a '

3 Compile-time (make) pop-up box error
"This program cannot be started because Libgcc_s_dw2-1.dll is missing in the computer. Try reinstalling the program to resolve the issue "or
The program can ' t start because libgcc_s_dw2-1.dll are missing from your computer. Try reinstalling to fix this problem.
The Windows environment variable and the environment variable (PATH) in the Msys are checked, and the C:\Qt\2010.05\mingw\bin is already included, and the directory has libgcc_s_dw2-1.dll, but

Problem still exists
Workaround: Copy Libgcc_s_dw2-1.dll (C:\Qt\2010.05\mingw\bin) to the directory of the EXE (Protoc.exe directory C:\TDDOWNLOAD\protobuf-

2.3.0\SRC)
There is a way to update libgcc_s_dw2-1.dll on the Internet, not try.
Reference: http://forums.codeblocks.org/index.php?topic=11313.0


4 will exist on Win7: the/bin/sh:/bin/install:permission denied error occurred while performing make install.
Solution: Increase the environment variable: PATH:D:\PROTOBUF-2.3.0\SRC. where Protoc.exe files exist

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.