私はDebian 8をCythonのパッケージインストール(apt-get install cython)で実行しています。pyximport with cgalビルドエラー:未定義シンボル "__gmpq_equal"
私はCGAL(www.cgal.org)と私の.pyxファイルをコンパイルするが、エラーが返されています:以下のファイルと
import pyximport; pyximport.install()
from spaces import spaces_rectangle
ImportError: Building module spaces failed: ['ImportError: /home/scootie/.pyxbld/lib.linux-x86_64-2.7/spaces.so: undefined symbol: __gmpq_equal\n']
:
spaces.pyx
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)
を
spaces.pyxbld:
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'])
とcgal_spaces.hpp:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Partition_traits_2.h>
#include <CGAL/Partition_is_valid_traits_2.h>
#include <CGAL/polygon_function_objects.h>
#include <CGAL/partition_2.h>
#include <cassert>
#include <list>
#include <vector>
{
*CODE HERE*
}
私が不適切にリンクするか、何かを明らかに行方不明です?
編集: pyximportの外でスクリプトをコンパイルすると問題なくコンパイルできます。
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
pyximportにgmpライブラリのリンクエラーがあるようです。すべての外部ライブラリにリンクする適切な方法は何ですか?
[ライブラリがリンクされている順序でGCCでエラーが発生することがあるのはなぜですか?](http://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-リンクされている - 時々原因 - エラーのgcc) –
これはまさにそれでした!私は解決策を説明するために私のメインポストに追加の編集を追加しました。簡単に円のように、ありがとう:) – scootie