Foreword
End communications equipment and equipment service, equipment service use Go to build, format and use protobuf end communications equipment, terminal equipment using stm32 series mcu, using C language development, so to generate protobuf C language version of the protocol library.
step
1. Prepare
yum -y install autoconf automake libtool
yum -y install gcc gcc-c++
2. Install protobuf
protobuf version Address: https://github.com/protocolbuffers/protobuf/releases ;
Tar.gz package using wget download, tar -zxvf decompression;
Decompression package, run ./autogen.sh, then ./configure,make & make install installation, of course ./configure --prefix = / usr / local / protobuf provided installation directory;
Test: protoc command;
At this time c language code can not be generated.
3. Installation protobuf-c
Set the environment variable: PKG_CONFIG_PATH = / usr / local / lib / pkgconfig, directory defined according to the installation directory, which is not configured installation configuration directory;
protobuf-c version Address: https://github.com/timesto/protobuf-c/releases ;
Tar.gz package using wget download, tar -zxvf decompression;
Decompression package, run ./autogen.sh, then ./configure,make & make install installation;
Test: protoc --c_out = msg.proto, generated .h and .c files.
4. Use
When using the reference required: https://github.com/timesto/protobuf-c Protobuf-C of the file;
After parsing, timely free.