CentOS 7.4 安装 protobuf-C

项目中需要单片机上位机和 javaweb 通信,上位机C语言编程,用到protobuf-C。

参考文章【按照参考价值从大到小排列】

https://www.linuxidc.com/Linux/2016-12/138716.htm

http://blog.chinaunix.net/uid-31343710-id-5757256.html

https://github.com/protobuf-c/protobuf-c/wiki/Examples

https://blog.csdn.net/ZHONGCAI0901/article/details/86608029

下面是安装过程中使用到的命令和相关说明:

我的安装目录:/usr/protobuf/install     


yum install autoconf
yum install automake
yum install libtool
yum install curl (used to download gmock)
yum install make
yum install g++


cd /usr/protobuf

tar zxvf protobuf-all-3.7.0.tar.gz

tar zxvf protobuf-c-1.3.1.tar.gz

cd protobuf-3.7.0

./configure --prefix=/usr/protobuf/install

make
----make check
----make install

vim /etc/profile
#protobuf
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/protobuf/install/lib
export LIBRARY_PATH=$LIBRARY_PATH:/usr/protobuf/install/lib
export PATH=$PATH:/usr/protobuf/install/bin


source /etc/profile

protoc --version

=============================================================

cd protobuf-c-1.3.1

export PKG_CONFIG_PATH=/usr/protobuf/install/lib/pkgconfig

./configure --prefix=/usr/protobuf/install

make    出现错误 和 警告

CXX    t/generated-code2/cxx_generate_packed_data-cxx-generate-packed-data.o
t/generated-code2/cxx-generate-packed-data.cc: In function ‘void dump_test_unknown_fields()’:
t/generated-code2/cxx-generate-packed-data.cc:1001:9: error: ‘Reflection’ in ‘class google::protobuf::Message’ does not name a type

cd /usr/protobuf/protobuf-c-1.3.1/t/generated-code2
vim cxx-generate-packed-data.cc
删除上面这一行,增加下面那一行
const google::protobuf::Message::Reflection *reflection = mess.GetReflection(); 
const google::protobuf::Reflection *reflection = mess.GetReflection();



----make check       出现警告忽略     
----make install

protoc-c

===========================================================

cd /usr/protobuf/proto

protoc-c --c_out=./ message.proto

=====================================
win

protoc ./message.proto --java_out=./


=======================
编码:
1、头文件 :#include 修改成 #include “protobuf-c.h”
2、头文件 :struct 之前加上 typedef



猜你喜欢

转载自blog.csdn.net/NRlovestudy/article/details/89786927