2012-12-10 14 views
7

मैं जब मैं इस जोड़नेअंक cython को

from libcpp.vector cimport vector 

का उपयोग कर cython और सिक्कों के नमूने रखने का बक्स फ़ाइल मैं यहाँ

python setup.py build_ext --inplace 
running build_ext 
skipping 'kmc_cy.c' Cython extension (up-to-date) 
building 'kmc_cy' extension 
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -I/usr/include/python2.7 -c kmc_cy.c -o build/temp.linux-x86_64-2.7/kmc_cy.o 
kmc_cy.c:254:18: fatal error: vector: No such file or directory 
compilation terminated. 
error: command 'gcc' failed with exit status 1 

मिल संकलित करने के लिए प्रयास करने के लिए वेक्टर वर्ग का आयात एक समस्या है मेरी setup.py है

from distutils.core import setup 
from distutils.extension import Extension 
from Cython.Distutils import build_ext 
import sys 
sys.path.append("/usr/lib64/python2.7/site-packages/Cython/Includes/libcpp") 

ext_modules = [Extension("kmc_cy", ["kmc_cy.pyx"])] 

setup(
    name = 'kmc_cy', 
    cmdclass = {'build_ext': build_ext}, 
    ext_modules = ext_modules, 
) 

चीयर्स

उत्तर

10
ext_modules = [Extension("kmc_cy", ["kmc_cy.pyx"],language='c++')] 

फिर g++gcc के बजाय इस्तेमाल किया जाना चाहिए और फ़ाइल नाम .cpp या .cc के साथ समाप्त करना चाहिए:std::vector के रूप में सी ++ कोड है, तो आप सही भाषा सेट करना होगा। अधिक जानकारी के लिए this answer देखें।

+0

ओह मेरे भगवान, धन्यवाद! : डी – bios