title: C++ GMP Library ostream operator<< compiles but doesn't link?
body: <pre><code>$ apt-cache show libgmp10
  Package: libgmp10
  ...
  Version: 2:5.0.2+dfsg-2ubuntu2
  </code></pre>
  
  <p><strong>test.cpp</strong>:</p>
  
  <pre><code>#include &lt;gmpxx.h&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      mpz_class x = 42;
  
      cout &lt;&lt; x;
  }
  </code></pre>
  
  <p><strong>compile:</strong></p>
  
  <pre><code>$ g++ -c test.cpp -o test.o
  $
  </code></pre>
  
  <p>OK</p>
  
  <p><strong>link:</strong></p>
  
  <pre><code>$ g++ test.o -lgmp
  test.o: In function `std::ostream&amp; operator&lt;&lt;
      &lt;__mpz_struct [1]&gt;(std::ostream&amp;,
           __gmp_expr&lt;__mpz_struct [1],
                __mpz_struct [1]&gt; const&amp;)':
  
  test.cpp:(.text._ZlsIA1_12__mpz_structERSoS2_RK10__gmp_exprIT_S4_E[_ZlsIA1_12__mpz_structERSoS2_RK10__gmp_exprIT_S4_E]+0x2a):
  
  undefined reference to `operator&lt;&lt;(std::ostream&amp;, __mpz_struct const*)'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>It can't find <code>operator&lt;&lt;(ostream&amp;, mpz_class)</code> at link time.  What gives?</p>