title: Linking protocol buffers library in XCode
body: <p>I want to use Google Protocol Buffers for C++ in XCode.<br>
  This is my directory where I have the library: <code>/Developer/Protobuf</code>.  </p>
  
  <p>What I did inside this directory, is compiled the <code>.proto</code> and produced the <code>.pb.h</code> &amp; .<code>pb.cc</code> files. After this produced the object file:  </p>
  
  <pre><code>clang++ -arch x86_64 -I./src -I./  -c file.pb.cc
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>ar -r file.pb.a file.pb.o
  </code></pre>
  
  <p>In XCode, in <code>Build Phases -&gt; Link Binary With Libraries</code> I have added <code>file.pb.a</code> static library. In <code>Build Settings -&gt; Header Search Paths</code> I have added <code>/Developer/Protobuf/src</code>. In <code>Build Settings -&gt; Librabry Search Paths</code> I have added <code>/Developer/Protobuf</code>. In <code>Build Settings -&gt; User Header Search Paths</code> I have added also <code>/Developer/Protobuf/src</code>.  </p>
  
  <p>But when I compiled the project I always get this kind of errors:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "google::protobuf::DescriptorPool::generated_pool()", referenced from:
        musicbrainz::protobuf_AssignDesc_musicbrainz_2eproto() in musicbrainz.pb.o
    "google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*, int)", referenced from:
        musicbrainz::protobuf_AddDesc_musicbrainz_2eproto() in musicbrainz.pb.o
    "google::protobuf::MessageFactory::generated_factory()", referenced from:
        musicbrainz::protobuf_AssignDesc_musicbrainz_2eproto() in musicbrainz.pb.o
    "google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;))", referenced from:
        musicbrainz::protobuf_AddDesc_musicbrainz_2eproto() in musicbrainz.pb.o
  .................................................................................
  </code></pre>
  
  <p>Maybe I am not creating the static library correct ?</p>