Hyperlink 如何将协议缓冲区(C+;+;)链接到Xcode
我在项目中添加了Hyperlink 如何将协议缓冲区(C+;+;)链接到Xcode,hyperlink,protocol-buffers,Hyperlink,Protocol Buffers,我在项目中添加了protobuf类“xxx.pb.h”,“xxx.pb.cc”。 我在标题搜索路径中添加了路径“/usr/local/include”, 并在库搜索路径中添加了路径“/usr/local/lib”。 现在我遇到了一个问题,, 生成时出现以下错误: ld: warning: ignoring file /usr/local/lib/libprotobuf.dylib, file was built for unsupported file format ( 0xcf 0xfa 0x
protobuf
类“xxx.pb.h”
,“xxx.pb.cc”
。
我在标题搜索路径中添加了路径“/usr/local/include”
,
并在库搜索路径中添加了路径“/usr/local/lib”
。
现在我遇到了一个问题,,
生成时出现以下错误:
ld: warning: ignoring file /usr/local/lib/libprotobuf.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /usr/local/lib/libprotobuf.dylib
ld: warning: ignoring file /usr/local/lib/libprotoc.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /usr/local/lib/libprotoc.dylib
Undefined symbols for architecture i386:
"google::protobuf::DescriptorPool::generated_pool()", referenced from:
protobuf_AssignDesc_person_2eproto() in person.pb.o
"google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*, int)", referenced from:
protobuf_AddDesc_person_2eproto() in person.pb.o
"google::protobuf::MessageFactory::generated_factory()", referenced from:
protobuf_AssignDesc_person_2eproto() in person.pb.o
。。。
按照本答案中提到的步骤操作->
这里和那里有一些陷阱,你可以检查相同的qn
这些是我遵循的不同步骤
我没有给出直到google目录的标题搜索路径,而是给出了直到“src/”目录的搜索路径
在任何导入xxx.pb.h
的文件中,都必须将.m
重命名为.mm
在Xcode 4.5中,我仍然收到一些链接器错误:
未找到架构i386的符号
由于这个原因,我无法在模拟器上运行。但是代码将在实际设备上运行。谢谢您的回答!我的方法是错误的。正确的步骤应该是这样的:1。您需要下载protocolbuf2.3.0版本,以创建“xxx.pb.h”和“xxx.pb.cc”文件。2.不要在中添加路径,只需在中添加“/usr/local/include”(这是默认安装路径)。3.不是添加“libprotobuf.a”和“libprotoc.a”库。要添加“libz.dylib”、“libxml2.dylib”和“libprotobuf.dylib”,也可以使用最新的protobuf。i、 e.第2.5版。此外,我遵循了答案中提到的步骤,这对我来说非常有效。我从不需要添加库搜索路径。
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for google::protobuf::Message", referenced from:
google::protobuf::Message::Message() in person.pb.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)