google protobuf src安装运行

在尝试安装google protobuf时遇到了autogen.sh执行失败的问题,通过在CentOS 6上执行`yum install libtool`解决了该问题。然而,之后在执行`make`时遇到了编译错误,错误涉及`InternalMetadataWithArena`和`InternalMetadataWithArenaLite`类的构造。通过修改源码中的注释,成功解决了编译错误并完成安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

学习运用google protobuf 使用

下载源码https://github.com/google/protobuf

如果是直接git的源码  按照src README.md 要求执行  ./autogen.sh 报错:autoreconf: /usr/bin/autoconf failed with exit status: 1

http://askubuntu.com/questions/449757/autogen-sh-script-failing-with-autoreconf2-50-automake-failed-with-exit-status 找到解决方法

我的系统是centos 6  执行 yum install libtool 后 再执行 ./autogen.sh 成功

执行make 在执行make 指令出现 在文件从./google/protobuf/any.pb.h:25包括,
从谷歌/的protobuf / any.pb.cc:5:
./google/protobuf/metadata.h:在构造'谷歌:: protobuf的::内部:: InternalMetadataWithArena :: InternalMetadataWithArena(谷歌:: protobuf的竞技场:: *)':
./google/protobuf/metadata.h:175:错误:类'谷歌:: protobuf的内部:: :: InternalMetadataWithArena“没有任何名为“InternalMetadataWithArenaBase”字段
./google/protobuf/metadata.h:在构造'谷歌:: protobuf的内部:: :: InternalMetadataWithArenaLite :: InternalMetadataWithArenaLite(谷歌:: protobuf的竞技场:: *)':
./google/protobuf/metadata .H:204:错误:类'谷歌:: protobuf的内部:: :: InternalMetadataWithArenaLite'没有名为任何领域“InternalMetadataWithArenaBase' 
让[2]:*** [谷歌/的protobuf / any.pb.lo]错误1 
使[2]:离开目录/home/protobuf/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory的/ home / protobuf的' 
使:*** [全部]错误2 

解决方案 :

 public:                                                                                                                                                                                                                                                                  
173   InternalMetadataWithArena() {}                                                                                                                                                                                                                                          
174   explicit InternalMetadataWithArena(Arena* arena)                                                                                                                                                                                                                        
175 //      : InternalMetadataWithArenaBase(arena) {}                                                                                                                                                                                                                         
176         : InternalMetadataWithArenaBase<UnknownFieldSet,InternalMetadataWithArena>(arena) {} 


 public:                                                                                                                                                                                                                                      
202   InternalMetadataWithArenaLite() {}                                                                                                                                                                                                                                      
203                                                                                                                                                                                                                                                                           
204   explicit InternalMetadataWithArenaLite(Arena* arena)                                                                                                                                                                                                                    
205 //      : InternalMetadataWithArenaBase(arena) {}                                                                                                                                                                                                                         
206         : InternalMetadataWithArenaBase<string,InternalMetadataWithArenaLite>(arena) {}        


然后在执行make  successs   


                                                                                                                                                                                                                                                                            


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值