2

我在项目中添加了protobuf类。我在 中添加了一条路径,并在其中添加了一条路径"xxx.pb.h""xxx.pb.cc""/usr/local/include"Header Search Paths"/usr/local/lib"Library Search Paths.

现在我遇到了一个问题,构建时出现以下错误:

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

……

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)

图片

4

1 回答 1

1

按照此答案中提到的步骤-> https://stackoverflow.com/a/10279656/1383704

这里和那里有一些陷阱,你可以检查我自己对相同 qn 的答案

这些是我遵循的不同步骤

  1. 我没有给出标题搜索路径直到 google 目录,而是给出了搜索路径直到“src/”目录

  2. 无论您导入哪个,xxx.pb.h都必须将其重命名.m.mm

在 Xcode 4.5 中,我仍然遇到一些链接器错误:

未找到体系结构 i386 的符号

因此,我无法在模拟器上运行。但代码将在实际设备上运行。

于 2013-03-06T13:22:57.027 回答