编译工程采用cmake编译
apt-get install cmake
cd code root;
mkdir build
cd build
cmake ../ (default:debug mode)
make -j
make install
open_src (开源代码 protobuf-c)
src (message 源码)
inc (message 对外api)
cmake 执行后自动生成多外的头文件,具体解析时由py脚本实现,需要编译环境支持python3 生成库文件libmsg.so
只需要增加*.proto文件,由cmake自动生成对外有文件和库文件。inc目录里都是外部需要用到的头文件
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!
ubuntu: apt-get install automake autoconf libtool
git clone --depth=1 https://github.com/protobuf-c/protobuf-c.git
protobuf-c's mailing list is hosted on a Google Groups forum. Subscribe by sending an email to [email protected].
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
See the online Doxygen documentation here or the Wiki for a detailed reference. The Doxygen documentation can be built from the source tree by running:
make html
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"