protobuf-c/README.md

56 lines
3.2 KiB
Markdown
Raw Normal View History

2014-06-02 18:17:02 -04:00
[![Build Status](https://travis-ci.org/protobuf-c/protobuf-c.png?branch=master)](https://travis-ci.org/protobuf-c/protobuf-c) [![Coverage Status](https://coveralls.io/repos/protobuf-c/protobuf-c/badge.png)](https://coveralls.io/r/protobuf-c/protobuf-c)
2013-11-18 00:12:57 -08:00
## Overview
2014-04-05 14:34:09 -04:00
This is `protobuf-c`, a C implementation of the [Google Protocol Buffers](https://developers.google.com/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](https://github.com/protobuf-c/protobuf-c-rpc) project.
2013-11-18 00:12:57 -08:00
2014-04-05 14:34:09 -04:00
`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!
2013-11-18 00:12:57 -08:00
## Mailing list
`protobuf-c`'s mailing list is hosted on a [Google Groups forum](https://groups.google.com/forum/#!forum/protobuf-c). Subscribe by sending an email to [protobuf-c+subscribe@googlegroups.com](mailto:protobuf-c+subscribe@googlegroups.com).
## Building
2013-11-18 00:12:57 -08:00
`protobuf-c` requires a C compiler, a C++ compiler, [protobuf](https://code.google.com/p/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
2014-04-05 14:28:09 -04:00
Use the `protoc-c` command to generate `.pb-c.c` and `.pb-c.h` output files from your `.proto` input file.
2014-04-05 14:28:09 -04:00
protoc-c --c_out=. example.proto
2014-04-05 14:28:09 -04:00
Include the `.pb-c.h` file from your C source code.
2014-04-05 14:28:09 -04:00
#include "example.pb-c.h"
2014-04-05 14:28:09 -04:00
Compile your C source code together with the `.pb-c.c` file. Add the output of the following command to your compile flags.
2014-04-05 14:28:09 -04:00
pkg-config --cflags 'libprotobuf-c >= 1.0.0'
2014-04-05 14:28:09 -04:00
Link against the `libprotobuf-c` support library. Add the output of the following command to your link flags.
2014-04-05 14:28:09 -04:00
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](https://www.flameeyes.eu/autotools-mythbuster/pkgconfig/pkg_check_modules.html) about the `PKG_CHECK_MODULES` macro.
## Versioning
`protobuf-c` follows the [Semantic Versioning Specification](http://semver.org/).
## Contributing
Please send patches to the [protobuf-c mailing list](https://groups.google.com/forum/#!forum/protobuf-c) 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](http://opensource.org/licenses/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.