g++ 链接 -lprotobuf 编译问题解决

项目场景:

在写自主实现rpc通讯框架的项目


问题描述

链接-lprotobuf编译的时候,进行:

g++ *.cc -lprotobuf

出现以下问题:

/usr/local/include/google/protobuf/metadata_lite.h:121:45:   required from ‘T* google::protobuf::internal::InternalMetadata::mutable_unknown_fields() [with T = std::basic_string<char>]/usr/local/include/google/protobuf/metadata_lite.h:250:67:   required from here
/usr/local/include/google/protobuf/metadata_lite.h:199:67: error: no matching function for call to ‘google::protobuf::Arena::Create(google::protobuf::Arena*&)’
     Container<T>* container = Arena::Create<Container<T>>(my_arena);
                                                                   ^
/usr/local/include/google/protobuf/metadata_lite.h:199:67: note: candidate is:
In file included from test.pb.h:24:0,
                 from test.pb.cc:4:
/usr/local/include/google/protobuf/arena.h:321:36: note: template<class T, class ... Args> static T* google::protobuf::Arena::Create(google::protobuf::Arena*, <type error>)
   PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) {
                                    ^
/usr/local/include/google/protobuf/arena.h:321:36: note:   template argument deduction/substitution failed:
......

解决方案:

在后面加入 【-std=c++11】

g++ *.cc -lprotobuf -std=c++11

编译即可正常通过。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值