Cython not recognizing c++11 commands
I'm wrapping a C++ class with Python, and I cannot compile any C++11 features with the Cython module.
Everything compiles okay when compiling the C++ alone. But when I run this setup.py below:
setup(
ext_modules = cythonize(
"marketdata.pyx", # our Cython source
sources=["cpp/OBwrapper.cpp, cpp/OrderBook/orderbook.h, cpp/OrderBook/orderbook.cpp"], # additional source file(s)
language="c++", # generate C++ code
extra_compile_args=["-std=c++11"]
))
In my .pyx file header:
# distutils: language = c++
# distutils: sources = cpp/OBwrapper.cpp cpp/OrderBook/orderbook.cpp
I get a ton of errors that have to do with them not recognizing c++11 commands, like 'auto'.
For example:
cpp/OrderBook/orderbook.cpp(168) : error C2065: 'nullptr' : undeclared identifier
How can I get this to work?
Try using Extension
: setup(ext_modules=cythonize([Extension(...)], ...)
.
This setup.py
works for me (on Debian Linux):
from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
from glob import glob
extensions = [
Extension(
'my_proj.cython.hello',
glob('my_proj/cython/*.pyx')
+ glob('my_proj/cython/*.cxx'),
extra_compile_args=["-std=c++14"])
]
setup(
name='my-proj',
packages=find_packages(exclude=['doc', 'tests']),
ext_modules=cythonize(extensions))
链接地址: http://www.djcxy.com/p/23768.html
上一篇: 我怎样才能让我的Python脚本更快?
下一篇: Cython不识别c ++ 11命令