<ios>
is a c++-header. The error message shows that you try to compile a C++-code as C-code.
Per default, Cython will produce a file with extension *.c
, which will be interpreted as C-code by the compiler later on.
Cython can also produce a file with the right file-extension for c++, i.e. *.cpp
. And there are multiple ways to trigger this behavior:
- adding
# distutils: language = c++
at the beginning of the pyx
-file.
- adding
language="c++"
to the Extension
definition in the setup.py
-file.
- call
cython
with option --cplus
.
- in IPython, calling
%%cython
magic with -+
, i.e. %%cython -+
.
- for alternatives when building with
pyximport
, see this SO-question.
Actually, for cythonize
there is no command line option to trigger c++-generation, thus the first options looks like the best way to go:
# distutils: language = c++
from spacy.structs cimport TokenC
print("loading")
The problem is that spacy/structs.pxd
uses c++-constructs, for example vectors or anything else cimported from libcpp
:
...
from libcpp.vector cimport vector
...
and thus also c++-libraries/headers are needed for the build.