title: pyximport with cgal build error: undefined symbol "__gmpq_equal"
body: <p>I am running Debian 8 with a packaged install of Cython (apt-get install cython).</p>
  
  <p>I am compiling my .pyx file with the CGAL (<a href="http://www.cgal.org" rel="nofollow">www.cgal.org</a>) but return the error:</p>
  
  <pre><code>import pyximport; pyximport.install()
  from spaces import spaces_rectangle
  </code></pre>
  
  <blockquote>
    <p>ImportError: Building module spaces failed: ['ImportError:
    /home/scootie/.pyxbld/lib.linux-x86_64-2.7/spaces.so: undefined symbol:
    __gmpq_equal\n']</p>
  </blockquote>
  
  <p>with the following files:</p>
  
  <p>spaces.pyx</p>
  
  <pre><code>from libcpp.vector cimport vector
  
  cdef extern from "cgal_spaces.hpp":
      cdef vector[vector[vector[double]]] wrap_spaces(vector[vector[double]])
  
  def spaces_rectangle(vector[vector[double]] rect):
      return wrap_spaces(rect)
  </code></pre>
  
  <p>spaces.pyxbld:</p>
  
  <pre><code>def make_ext(modname, pyxfilename):
      from distutils.extension import Extension
      return Extension(name=modname,
                       sources=[pyxfilename],
                       include_dirs=['.'],
                       libraries=['CGAL'],
                       language='c++',
                       extra_compile_args=['-std=c++11'])
  </code></pre>
  
  <p>and cgal_spaces.hpp:</p>
  
  <pre><code>#include &lt;CGAL/Exact_predicates_inexact_constructions_kernel.h&gt;
  #include &lt;CGAL/Partition_traits_2.h&gt;
  #include &lt;CGAL/Partition_is_valid_traits_2.h&gt;
  #include &lt;CGAL/polygon_function_objects.h&gt;
  #include &lt;CGAL/partition_2.h&gt;
  #include &lt;cassert&gt;
  #include &lt;list&gt;
  #include &lt;vector&gt;
  {
      *CODE HERE*
  }
  </code></pre>
  
  <p>Am I linking improperly or missing something obvious??</p>
  
  <p>Edit:
  If I compile the script outside of pyximport, it compiles with no problem. </p>
  
  <pre><code>cython -a spaces.pyx
  g++ -std=c++11 -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.7 -o spaces.so spaces.c
  </code></pre>
  
  <p>It seems there's a linking error in the pyximport with the gmp library. What's the proper way to linking to all external libraries?</p>