2016-08-20 2 views
-1

나는이 사이 썬의 설치 패키지화와 데비안 8을 실행하고 정의되지 않은 기호 "__gmpq_equal"(apt-get을 사이 썬 설치).CGAL 빌드 오류와 pyximport :

내가 CGAL 내 .pyx 파일 (www.cgal.org)를 컴파일 있지만 오류 반환하고 다음 파일과

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 라이브러리의 링크 오류가있는 것 같습니다. 모든 외부 라이브러리에 연결하는 적절한 방법은 무엇입니까?

+0

가능한 중복 [왜 라이브러리가 가끔 연결되는 순서는 GCC에서 오류가 발생합니까?] (http://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries- - 연결되어 때로는 원인-오류 -에 - GCC이 정확히) –

+0

했다! 솔루션을 설명하기 위해 메인 포스트에 추가 편집을 추가했습니다. 파이처럼 쉽게, 감사합니다 :) – scootie

답변

0
라이브러리가 라이브러리에서 누락 될 수 있습니다

GMP,

strings -f /usr/lib/x86_64-linux-gnu/*.a |grep gmpq_equal 

출력

/usr/lib/x86_64-linux-gnu/libgmp.a: __gmpq_equal 
/usr/lib/x86_64-linux-gnu/libgmp.a: __gmpq_equal 
+0

나는 라이브러리가 거기에 있음을 제안하는 동일한 출력을 반환합니다 : 'strings -f /usr/lib/x86_64-linux-gnu/*.a | 그렙 gmpq_equal /usr/lib/x86_64-linux-gnu/libgmp.a : __gmpq_equal /usr/lib/x86_64-linux-gnu/libgmp.a : 나는 소스는 apt를 통해 모두 CGAL를 설치 한 __gmpq_equal'을 pyximport 외부에서 벌금을 컴파일합니다. – scootie

1

솔루션 : 나는 * .pyxbld에 GMP 라이브러리를 추가 한

def make_ext(modname, pyxfilename): 
    from distutils.extension import Extension 
    return Extension(name=modname, 
       sources=[pyxfilename], 
       include_dirs=['.'], 
       libraries=['CGAL','gmp'], 
       language='c++', 
     extra_compile_args=['-std=c++11','-DCGAL_ROOT="/path/to/CGAL-4.8.1"']) 

하지만, 해결책은 "-std = C++ 11"다음에 -DCGAL_ROOT를 배치하는 것입니다. 의

+0

당신은 본질적으로 내 대답의 일부를 반복하고있다 "GMP 라이브러리는 라이브러리에서 누락 될 수 있습니다 ...". 그'-DCGAL_ROOT = "/ path/to/CGAL-4.8.1"은 다소 이상하며 더 자세히 설명해야합니다. 나는 컴파일 과정에 영향을 미친다. –

+1

'gmp'를 libararies에 추가 한 후에도 컴파일되지 않았습니다. 소스에서 CGAL을 설치하고 설치된 경로에 연결 한 후에 만 ​​컴파일됩니다. 또한, 이것은 데비안 8 문제로 보입니다. Fedora20에서 오류없이 컴파일되었습니다. – scootie