我在Project中添加了protobuf
类"xxx.pb.h"
,"xxx.pb.cc"
。
我在"/usr/local/include"
中添加了路径Header Search Paths
,
并在"/usr/local/lib"
Library Search Paths.
现在我遇到了一个问题, Build中的以下错误:
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)
答案 0 :(得分:1)
按照此回答中提到的步骤 - > https://stackoverflow.com/a/10279656/1383704
这里和那里有一些陷阱,您可以检查my own answer是否有相同的qn。
这些是我遵循的不同步骤
而不是给google目录提供标题搜索路径,我给了搜索路径,直到“src /”目录
无论您导入xxx.pb.h
,都必须将.m
重命名为.mm
在Xcode 4.5中,我仍然遇到一些链接器错误:
未找到架构i386的符号
因此我无法在模拟器上运行。但代码将在实际设备上运行。