安装protobuf
从https://github.com/protocolbuffers/protobuf下载protobuf,解压、进入,执行:
./configure
make
make check
make install
安装时遇到的问题
问题一
./configure报错:./include/gtest/internal/gtest-port.h:428:10: fatal error: ‘tr1/tuple’ file not found
解决方法
进入解压后的protobuf2.4.1目录,输入命令【./autogen.sh】生成configure文件
然后执行./configure CPPFLAGS=-DGTEST_USE_OWN_TR1_TUPLE=1
问题二
make时报错:google/protobuf/message.cc:175:16: error: implicit instantiation of undefined template
解决方法
编辑目录下的文件./src/google/protobuf/message.cc,添加头文件#include <istream>
定义.proto文件
person.proto:
option java_package = "com.bbllbb";
option java_outer_classname = "PersonEntity";
message Person {
required int32 id = 1;
required string name = 2;
optional strin