title: Undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]
body: <p>I'm trying to build simple test application with Protocol Buffers 2.6.1 and GNU GCC 5.1.0 (on Ubuntu 14.10) and I get following errors:</p>
  
  <pre><code>/home/ragnar/cpp-tools/gcc-linux/bin/g++   -c  "/home/ragnar/cpp-projects/gprotobuf_test/main.cpp" -g -O0 -Wall   -o ./Debug/main.cpp.o -I. -I/home/ragnar/cpp-tools/libs/linux64/protobuf/include -I.
  /home/ragnar/cpp-tools/gcc-linux/bin/g++   -c  "/home/ragnar/cpp-projects/gprotobuf_test/messages.pb.cc" -g -O0 -Wall   -o ./Debug/messages.pb.cc.o -I. -I/home/ragnar/cpp-tools/libs/linux64/protobuf/include -I.  
  /home/ragnar/cpp-tools/gcc-linux/bin/g++  -o ./Debug/gprotobuf_test @"gprotobuf_test.txt" -L. -L/home/ragnar/cpp-tools/libs/linux64/protobuf/lib  -lprotobuf  
  ./Debug/main.cpp.o: In function google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]():  
    /home/ragnar/cpp-tools/libs/linux64/protobuf/include/google/protobuf/generated_message_util.h:80: 
      undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]  
    /home/ragnar/cpp-tools/libs/linux64/protobuf/include/google/protobuf/generated_message_util.h:81: 
      undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]  
  ./Debug/messages.pb.cc.o: In function protobuf_AssignDesc_messages_2eproto():  
    /home/ragnar/cpp-projects/gprotobuf_test/messages.pb.cc:32: 
      undefined reference to google::protobuf::DescriptorPool::FindFileByName(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const  
  ./Debug/messages.pb.cc.o: In function protobuf_AddDesc_messages_2eproto():  
    /home/ragnar/cpp-projects/gprotobuf_test/messages.pb.cc:83: 
      undefined reference to google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;))  
  ./Debug/messages.pb.cc.o: In function my_message::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*):
    /home/ragnar/cpp-projects/gprotobuf_test/messages.pb.cc:187: 
      undefined reference to google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;*)  
  ./Debug/messages.pb.cc.o: In function my_message::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const:
    /home/ragnar/cpp-projects/gprotobuf_test/messages.pb.cc:247: 
      undefined reference to google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, google::protobuf::io::CodedOutputStream*)  
  ./Debug/messages.pb.cc.o: In function google::protobuf::internal::WireFormatLite::WriteStringToArray(int, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, unsigned char*):
    /home/ragnar/cpp-tools/libs/linux64/protobuf/include/google/protobuf/wire_format_lite_inl.h:749: 
      undefined reference to google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, unsigned char*)  
  ./Debug/messages.pb.cc.o:(.rodata._ZTV10my_message[_ZTV10my_message]+0x20): 
      undefined reference to google::protobuf::Message::GetTypeName[abi:cxx11]() const  
   ./Debug/messages.pb.cc.o:(.rodata._ZTV10my_message[_ZTV10my_message]+0x40): 
      undefined reference to google::protobuf::Message::InitializationErrorString[abi:cxx11]() const  
  collect2: error: ld returned 1 exit status  
  gprotobuf_test.mk:93: recipe for target "Debug/gprotobuf_test" failed  
  make[1]: *** [Debug/gprotobuf_test] Error 1  
  make[1]: Leaving directory "/home/ragnar/cpp-projects/gprotobuf_test"  
  Makefile:4: recipe for target "All" failed  
  make: *** [All] Error 2  
  </code></pre>
  
  <p>The /home/ragnar/cpp-tools/libs/linux64/protobuf/lib contains following libraries:  </p>
  
  <pre><code>libprotobuf.a  
  libprotobuf.so.9.0.1  
  libprotobuf-lite.a  
  libprotobuf-lite.so.9.0.1  
  libprotoc.a  
  libprotoc.so.9.0.1  
  </code></pre>
  
  <p>Here's the simple messages.proto file:</p>
  
  <pre><code>option java_package = "my.package";
  
  message my_message {
    required string word = 1;
    required uint32 number = 2;
  }
  </code></pre>
  
  <p>and the code I'm trying to get working:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;google/protobuf/io/coded_stream.h&gt;
  #include &lt;google/protobuf/io/zero_copy_stream_impl.h&gt;
  #include "messages.pb.h"
  
  std::vector&lt;unsigned char&gt; encode( google::protobuf::Message &amp; msg )
  {
    std::vector&lt;unsigned char&gt; data( msg.ByteSize() + 
      google::protobuf::io::CodedOutputStream::VarintSize32( msg.ByteSize() ) );
    google::protobuf::io::ArrayOutputStream array_out( &amp;data[0], data.size() );
    google::protobuf::io::CodedOutputStream coded_out( &amp;array_out );
    coded_out.WriteVarint32( msg.ByteSize() );
    msg.SerializeToCodedStream( &amp;coded_out );
    return data;
  }
  
  void decode( const std::vector&lt;unsigned char&gt; &amp; data, google::protobuf::Message &amp; msg )
  {
    google::protobuf::io::ArrayInputStream array_in( &amp;data[0] , data.size() );
    google::protobuf::io::CodedInputStream coded_in( &amp;array_in );
    google::protobuf::uint32 size;
    coded_in.ReadVarint32( &amp;size );
    google::protobuf::io::CodedInputStream::Limit msg_limit = coded_in.PushLimit( size );
    msg.ParseFromCodedStream( &amp;coded_in );
    coded_in.PopLimit( msg_limit );
  }
  
  int main(int argc, char **argv)
  {
    my_message in_msg;
    in_msg.set_word( \"blah blah\" );
    in_msg.set_number( 123 );
    std::vector&lt;unsigned char&gt; data = encode( in_msg );
  
    my_message out_msg;
    decode( data, out_msg );
    std::cout &lt;&lt; \"word: \" &lt;&lt; out_msg.word() &lt;&lt; \" number: \" &lt;&lt; out_msg.number() &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>
  
  <p>Gcc is built from source with following options:</p>
  
  <pre><code>--enable-64bit --enable-32bit --enable-languages=c,c++ --enable-multilib
  --disable-nls --enable-threads=posix --enable-checking=release
  --enable-lto --enable-multiarch --with-multilib-list=m32,m64,mx32 
  --with-tune=generic --enable-shared --with-glibc-version=2.13
  --enable-libstdcxx-time=rt
  </code></pre>
  
  <p>and Protobuf is built from source with following options:  </p>
  
  <pre><code>--enable-64it --disable-32bit --enable-shared CXXFLAGS=-m64 -DNDEBUG LDFLAGS=-m64
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>