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-gen-c, a code generator plugin for protoc that converts Protocol Buffer .proto files to C descriptor code. protobuf-c formerly included an RPC implementation; that code has been split out into the protobuf-c-rpc project.
./build.sh --prefix=<install prefix>
Use the protoc command to generate .pb-c.c and .pb-c.h output files from your .proto input file. The --c_out options instructs protoc to use the protobuf-c plugin.
protoc --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'
protobuf-c follows the Semantic Versioning Specification as of version 1.0.0.
Note that as of version of 1.0.0, the header files generated by the protobuf-c compiler contain version guards to prevent incompatibilities due to version skew between the generated .pb-c.h files and the public protobuf-c.h include file supplied by the libprotobuf-c support library. While we will try not to make changes to protobuf-c that will require triggering the version guard often, such as releasing a new major version of protobuf-c, this cannot be guaranteed. Thus, it's a good idea to recompile your .pb-c.c and .pb-c.h files from their source .proto files with protoc as part of your build system, with proper source file dependency tracking, rather than shipping potentially stale .pb-c.c and .pb-c.h files that may not be compatible with the libprotobuf-c headers installed on the system in project artifacts like repositories and release tarballs. (Note that the output of the protobuf-c code generator is not standalone, as the output of some other tools that generate C code is, such as flex and bison.)
Major API/ABI changes may occur between major version releases, by definition. It is not recommended to export the symbols in the code generated by the protobuf-c compiler in a stable library interface, as this will embed the protobuf-c ABI into your library's ABI. Nor is it recommended to install generated .pb-c.h files into a public header file include path as part of a library API, as this will tie clients of your library's API to particular versions of libprotobuf-c.