Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Protobuf compiled and used on the Ubuntu 14.04     - MySQL loose index scan (Database)

- Distributed File System using MogileFS (Linux)

- VMware Workstation virtual machine startup error: Could not open / dev / vmmon in CentOS 6 (Linux)

- RHEL5 establish a local yum source (Linux)

- Android development environment to build under Fedora 13 (Linux)

- Elasticsearch 2.20 Beginners: aggregation (Server)

- Ubuntu amend resolv.conf restart failure problem (Linux)

- CentOS minimal network is unavailable resolved (Linux)

- Linux Log Clear (Linux)

- QEMU image file used: qcow2 and raw (Linux)

- To install the Git and Github under Ubuntu (Linux)

- CentOS install video converter FFmpeg and cutting tools segmenter (Linux)

- File permissions under Linux (Linux)

- CentOS6 installed Tomcat (Server)

- VirtualBox modify the size of the virtual machine disk VDI (Linux)

- Debian 7.8 system installation and configuration process (Linux)

- Oracle how to assess the true concurrent session (Database)

- MongoDB common optimization settings in Linux (Database)

- Linux file and directory permissions settings (Linux)

- mysqldump issue a note (Database)

  Protobuf compiled and used on the Ubuntu 14.04
  Add Date : 2018-11-21      
  Abstract: Protobuf compiled and used on the Ubuntu 14.04


It has nothing to do know a language Google open source data exchange protocol: protobuf. Only know that is a different json and XML format, there is a particularly good performance (which is indeed in Java C ++ implementations and!)

Google recently retired and sit looked under the Protobuf related stuff, but baidu out a lot of things are out of date, I had to take the time to shift, so there is the following content.

• download the source code and the preparatory work

$ Sudo apt-get install autoconf automake libtool curl
$ Git clone https://github.com/google/protobuf
$ Cd protobuf
• Modify autogen.sh

Because "you know" reasons, autogen can not curl to download the source code package gmock, so I gmock bag put on his github. Modify autogen.sh, download it on my bag github

peter @ ubuntu14: ~ / protobuf / protobuf $ git diff
diff --git a / autogen.sh b / autogen.sh
index 5b4c29f..f2abf77 100755
--- A / autogen.sh
+++ B / autogen.sh
@@ -31,7 +31,7 @@ Fi
 # Directory is set up as an SVN external.
 ! If test -e gmock; then
  echo "Google Mock not present. Fetching gmock-1.7.0 from the web ..."
- Curl $ curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
+ Curl $ curlopts -L -o gmock-1.7.0.zip https://github.com/peter-wangxu/gMock/archive/1.7.0.zip
  unzip -q gmock-1.7.0.zip
  rm gmock-1.7.0.zip
  mv gmock-1.7.0 gmock

# The curl green line that replaced
• generated configure file

$ ./autogen
• Compiling and Installing protobuf

$ ./configure
$ Make
$ Make check
$ Sudo make install
$ Sudo ldconfig # refresh shared library cache.

NOTE: The default is installed in "/ usr / local / lib", and in some platform / usr / local / lib LD_LIBRARY_PATH variable which is not the default, you can change the installation directory with the following command

$ ./configure --prefix = / Usr

When you see something like the following text, completed the basic installation instructions protobuf

================================================== ==========================
Testsuite summary for Protocol Buffers 3.0.0-beta-2
================================================== ==========================
# TOTAL: 6
# PASS: 6
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
================================================== ==========================

Then there is the Python language associated with some of the configuration

• installation of Python support protobuf

cd python # located at protobuf
sudo python setup.py install

NOTE: If the above command fails, you can try to install under pip related packages can Depends some python packages

sudo apt-get install python-pip

-------------------------------------------------- ------------------------------

The next step is to use the protobuf
• Compile .proto file

$ Touch DataService.proto
# Into the following

message RowProto {
required uint32 null_map = 1;
repeated string column = 2;

message TableProto {
repeated string column = 1;
repeated string row = 2;

• produce py file for later use Python

protoc --python_out =. ./DataService.proto
• protobuf use

Create TestDataService.py file, add the following content

import sys
import DataService_pb2

#create proto
row = DataService_pb2.RowProto ()
row.null_map = 1
row.column.append ( "wang")
row.column.append ( "female")
row_str = row.SerializeToString ()
print "row_str:", row_str
table = DataService_pb2.TableProto ()
table.column.append ( "name")
table.column.append ( "gender")
table.row.append (row_str)
table_str = table.SerializeToString ()

#process proto
table_proto = DataService_pb2.TableProto ()
table_proto.ParseFromString (table_str)
print "column:"
print table_proto.column

row_str = table_proto.row [0]
row_proto = DataService_pb2.RowProto ()
row_proto.ParseFromString (row_str.encode ( 'utf8'))
print "row1:"
print row_proto.column

Run TestDataServer.py

peter @ ubuntu14: ~ / protobuf / proto_test $ python TestDataService.py
row_str: wangfemale
[U'name ', u'gender']
[U'wang ', u'female']

Thus the contents of this issue, the main installation and configuration protobuf using involves little behind time will add more content related to the use

-------------------------------------------------- ------------------------------


If you encounter:

protoc: error while loading shared libraries: libprotoc.so.10: can not open shared object file: No such file or directory


sudo ldconfig
- Python cause yum upgrade error (Linux)
- HBase Application Development Review and Summary of Series (Database)
- Android Fragment everything you need to know (Programming)
- Linux Network Programming --epoll model Detailed principles and examples (Programming)
- Linux server security settings to close unused ports (Linux)
- Cross server / client backup command: rsync use (Server)
- sudoers file parsing (Linux)
- Summary Linux bond of multi-interface load balancing (Linux)
- Linux kernel socket protocol stack routing lookup cache mechanism (Linux)
- Android Studio Installation and Configuration Guide tutorial (Linux)
- Linux 4.0+ kernel support for hardware switching module (HW Switch Offload) (Linux)
- Linux process or thread is bound to a CPU (Programming)
- Linux ldconfig command (Linux)
- Basic data types JavaScript type system and the type of packaging (Programming)
- Performance issues under CentOS 6.5 VLAN devices (Linux)
- The Gitlab migrated to Docker container (Server)
- LinkedList Basic Usage (Programming)
- xCAT deployment (Linux)
- To install HDRMerge 0.4.3 under ubuntu (Linux)
- PostgreSQL Source Customization: Online global read only (Database)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.