Linker error for functions expecting const std::string &
<p>When trying to link against a shared library (<em>gtkmm</em>), I get linker errors for functions whose signature contains a <code>std::string const&amp;</code>.</p>

<p>For example, if the function is declared as</p>

<pre class="lang-cpp prettyprint-override"><code>void set_icon_from_file(const std::string&amp;);
</code></pre>

<p>g++ reports</p>

<pre><code>undefined reference to `Gtk::Window::set_icon_from_file(std::string const&amp;)'
</code></pre>

<p>I am using the linker flags from <code>pkg-config</code>, and this does not happen for other functions (functions taking primitive types as arguments, for example), so I suspect the linker is configured properly.</p>

<p><code>readelf</code> on my object file gives me </p>

<pre><code>45: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZN3Gtk6Window18set_icon_from_fileERKSs
</code></pre>

<p>and on the shared library </p>

<pre><code>10991: 00000000003c0950    96 FUNC    GLOBAL DEFAULT   11 _ZN3Gtk6Window18set_icon_from_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
</code></pre>

<p>I'm not sure what to make of that. I checked that the functions are declared with the same signature in both the library headers and source. Because of the <code>__cxx11</code> part in the mangled name, I first suspected a compatibility issue between C++ versions, however, I'm building with C++11 as well.</p>