Undefined reference when linking protobuf
<p>I'm working on a Mac. I installed libprotobuf with <code>brew install protobuf --c++11</code>.</p>

<pre><code>17:51 $ brew info protobuf
protobuf: stable 2.6.1 (bottled), devel 3.0.0-beta-4, HEAD
Protocol buffers (Google's data interchange format)
https://github.com/google/protobuf/
/usr/local/Cellar/protobuf/2.6.1 (149 files, 7.0M) *
  Built from source on 2016-08-02 at 17:42:15 with: --c++11
</code></pre>

<p><code>libprotobuf.dylib</code> lives in <code>/usr/local/Cellar/protobuf/2.6.1/lib</code>.</p>

<p>I wrote the following dummy app hoping to invoke <a href="https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream_impl_lite#StringOutputStream.StringOutputStream.details" rel="nofollow">this constructor</a>:</p>

<pre><code>// test.cc
#include &lt;string&gt;
#include &lt;google/protobuf/io/coded_stream.h&gt;
#include &lt;google/protobuf/io/zero_copy_stream_impl_lite.h&gt;

int main() {
  std::string s{"hello"};
  google::protobuf::io::StringOutputStream sos(&amp;s);
}
</code></pre>

<p>When I compile the app, I get an undefined reference error:</p>

<pre><code>17:55 $ g++ -L/usr/local/Cellar/protobuf/2.6.1/lib -std=c++14 test.cc -lprotobuf
Undefined symbols for architecture x86_64:
  "google::protobuf::io::StringOutputStream::StringOutputStream(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;*)", referenced from:
      _main in ccyQlDM5.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
</code></pre>

<p>When I check the <code>.dylib</code> for <code>StringOutputStream</code>, it's a little wonky.</p>

<pre><code>17:56 $ nm /usr/local/Cellar/protobuf/2.6.1/lib/libprotobuf.dylib | c++filt | grep "StringOutputStream(std::"
000000000000e3ac T google::protobuf::io::StringOutputStream::StringOutputStream(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;*)
000000000000e398 T google::protobuf::io::StringOutputStream::StringOutputStream(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;*)
</code></pre>

<p>Why is <code>basic_string</code> namespace-prefixed by <code>::__1</code> in my list of symbols for that <code>.dylib</code>? How can I fix this?</p>

<p>If this isn't a problem (perhaps an artifact of unmangling), why am I still receiving an undefined reference to a constructor call I know to be defined?</p>

<p>I'm using <code>gcc 5.3.0</code> to compile <code>test.cc</code>.</p>