项目场景:
在写自主实现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
编译即可正常通过。