Installing Google Protocol Buffers

The serialization framework "google protocol buffers" is a fast and flexible way to serialize messages.

It can be used with nearly any programming language, e.g. C++, Matlab and Java.

To use it on Ubuntu 12.04 you can install it in the following way:


sudo apt-get install protobuf-compiler
sudo apt-get install libprotobuf-dev


If you use qmake, add the following file to your project:

# Qt qmake integration with Google Protocol Buffers compiler protoc
# To compile protocol buffers with qt qmake, specify PROTOS variable and
# include this file
# Example:
# LIBS += /usr/lib/
# PROTOS = a.proto b.proto
# include(protobuf.pri)
# By default protoc looks for .proto files (including the imported ones) in
# the current directory where protoc is run. If you need to include additional
# paths specify the PROTOPATH variable

PROTOPATH += ../Protocol
for(p, PROTOPATH):PROTOPATHS += --proto_path=$${p} = protobuf header
protobuf_decl.input = PROTOS
protobuf_decl.output = ${QMAKE_FILE_BASE}.pb.h
protobuf_decl.commands = protoc --cpp_out="." $${PROTOPATHS} ${QMAKE_FILE_NAME}
protobuf_decl.variable_out = GENERATED_FILES
QMAKE_EXTRA_COMPILERS += protobuf_decl = protobuf implementation
protobuf_impl.input = PROTOS
protobuf_impl.output = ${QMAKE_FILE_BASE}
protobuf_impl.depends = ${QMAKE_FILE_BASE}.pb.h
protobuf_impl.commands = $$escape_expand(\n)
protobuf_impl.variable_out = GENERATED_SOURCES
QMAKE_EXTRA_COMPILERS += protobuf_impl

Save it as protobuf.pri .

Back to FrontPage

KielTech: Google Protocol Buffers (last edited 2013-06-23 13:53:03 by UweFechner)