How can i Linking the Protocol Buffer(C++) into the Xcode-Collection of common programming errors

I added the protobuf class "xxx.pb.h","xxx.pb.cc" in Project. I added a path"/usr/local/include" in Header Search Paths, and added a path"/usr/local/lib" in Library Search Paths.

Now I encountered a problem, The following error at 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)

Image

  1. Follow the steps mentioned in this answer -> http://stackoverflow.com/a/10279656/1383704

    There are a few pitfalls here and there, for which you may check my own answer for the same qn.

    These were the steps I followed differently

    1. instead of giving header search path till google directory, i gave the search path till the “src/” directory

    2. In whichever you import your xxx.pb.h you have to rename the .m to .mm

    In Xcode 4.5 i was still getting some linker errors :

    symbols not found for architecture i386

    Because of this I wasn’t able to run on simulator. But the code will run on actual device.

Originally posted 2013-11-19 13:17:46.