Issue including std::vector to cython
cython, import, vector
Solution
As `std::vector` is C++ code, you need to set the correct language:
ext_modules = [Extension("kmc_cy", ["kmc_cy.pyx"],language='c++')]
Then `g++` should be used instead of `gcc` and the file name should end with `.cpp` or `.cc`. See this answer for more details.
Problem
I have a problem importing the vector class to cython using ``` from libcpp.vector cimport vector ``` when I add this and try to compile the pyx file I get ``` 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 ``` Here is my 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, ) ``` Cheers