exact version coupling between the compiler and the public headers is too strict because some existing projects (such as collectd, riemann-c-client, and nmsg) directly embed .pb-c.h files generated by protoc-c into their exported headers. this would cause unnecessary build failures in downstream clients of these libraries if a newer version of the protobuf-c headers is installed. however, it's still desireable to be able to explicitly declare when compatibility is broken between the headers and the compiler, so introduce new variables that allow independently setting the minimum header version required by the compiler and the minimum compiler version required by the header. this follows the protobuf C++ implementation a little bit more closely, though we don't have an analogous facility for verifying that the header and *library* are compatible. (this seems like overkill for a C project; in practice the headers and the library will be from the same version, especially in downstream distributors like debian where the -dev package has an exact versioned dependency on the shared library package.)
Overview
This is protobuf-c
, a C implementation of the Google Protocol Buffers data serialization format. It includes libprotobuf-c
, a pure C library that implements protobuf encoding and decoding, and protoc-c
, a code generator that converts Protocol Buffer .proto
files to C descriptor code, based on the original protoc
. protobuf-c
formerly included an RPC implementation; that code has been split out into the protobuf-c-rpc project.
protobuf-c
was originally written by Dave Benson and maintained by him through version 0.15 but is now being maintained by a new team. Thanks, Dave!
Mailing list
protobuf-c
's mailing list is hosted on a Google Groups forum. Subscribe by sending an email to protobuf-c+subscribe@googlegroups.com.
Building
protobuf-c
requires a C compiler, a C++ compiler, protobuf, and pkg-config
to be installed.
./configure && make && make install
If building from a git checkout, the autotools
(autoconf
, automake
, libtool
) must also be installed, and the build system must be generated by running the autogen.sh
script.
./autogen.sh && ./configure && make && make install
Synopsis
Use the protoc-c
command to generate .pb-c.c
and .pb-c.h
output files from your .proto
input file.
protoc-c --c_out=. example.proto
Include the .pb-c.h
file from your C source code.
#include "example.pb-c.h"
Compile your C source code together with the .pb-c.c
file. Add the output of the following command to your compile flags.
pkg-config --cflags 'libprotobuf-c >= 1.0.0'
Link against the libprotobuf-c
support library. Add the output of the following command to your link flags.
pkg-config --libs 'libprotobuf-c >= 1.0.0'
If using autotools, the PKG_CHECK_MODULES
macro can be used to detect the presence of libprotobuf-c
. Add the following line to your configure.ac
file:
PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c >= 1.0.0])
This will place compiler flags in the PROTOBUF_C_CFLAGS
variable and linker flags in the PROTOBUF_C_LDFLAGS
variable. Read more information here about the PKG_CHECK_MODULES
macro.
Versioning
protobuf-c
follows the Semantic Versioning Specification.
Contributing
Please send patches to the protobuf-c mailing list or by opening a GitHub pull request.
Copyright to all contributions are retained by the original author, but must be licensed under the terms of the BSD-2-Clause license. Please add a Signed-off-by
header to your commit message (git commit -s
) to indicate that you are licensing your contribution under these terms.