Protocol buffers 在xcode中使用protobuf 3时获取链接错误
首先,我安装了google protobuf-3.3(protobuf-cpp-3.3.0.tar.gz),使用xcode创建一个跨平台游戏项目,目标是ios,添加libprotobuf-lite.tbd和libprotobuf.tbd,然后创建一个test.proto文件,如下所示:Protocol buffers 在xcode中使用protobuf 3时获取链接错误,protocol-buffers,Protocol Buffers,首先,我安装了google protobuf-3.3(protobuf-cpp-3.3.0.tar.gz),使用xcode创建一个跨平台游戏项目,目标是ios,添加libprotobuf-lite.tbd和libprotobuf.tbd,然后创建一个test.proto文件,如下所示: syntax = "proto3"; message Person { string name = 1; } 使用protoc将其编译为cpp文件:test.pb.h,test.pb.cc 在运行项目时,
syntax = "proto3";
message Person {
string name = 1;
}
使用protoc将其编译为cpp文件:test.pb.h,test.pb.cc
在运行项目时,我发现了13个错误:
Undefined symbols for architecture arm64:
"google::protobuf::Message::SpaceUsedLong() const", referenced from:
vtable for Person in test.pb.o
"google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)", referenced from:
Person::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in test.pb.o
Person::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const in test.pb.o
Person::InternalSerializeWithCachedSizesToArray(bool, unsigned char*) const in test.pb.o
"google::protobuf::UnknownFieldSet::default_instance()", referenced from:
google::protobuf::internal::InternalMetadataWithArena::default_instance() in test.pb.o
"google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)", referenced from:
Person::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) in test.pb.o
"google::protobuf::internal::RegisterAllTypes(google::protobuf::Metadata const*, int)", referenced from:
protobuf_test_2eproto::(anonymous namespace)::protobuf_RegisterTypes(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in test.pb.o
...
...
...
架构arm64的未定义符号:
“google::protobuf::Message::SpaceUsedLong()const”,引用自:
测试人员的vtable.pb.o
“google::protobuf::internal::WireFormatLite::VerifyUtf8String(字符常量*,int,google::protobuf::internal::WireFormatLite::Operation,字符常量*)”,引用自:
test.pb.o中的Person::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)
test.pb.o中的Person::SerializeWithCachedSizes(google::protobuf::io::CodeDoutpOutStream*)常量
Person::test.pb.o中InternalSerializeWithCachedSizeStoreArray(bool,unsigned char*)常量
“google::protobuf::UnknownFieldSet::default_instance()”,引用自:
test.pb.o中的google::protobuf::internal::InternalMetadataWithArena::default_instance()
“google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)”,引用自:
test.pb.o中的Person::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)
“google::protobuf::internal::RegisterAllTypes(google::protobuf::Metadata const*,int)”,引用自:
protobuf_test_2eproto:(匿名名称空间)::test.pb.o中的protobuf_注册表类型(std::_1::basic_string const&)
...
...
...