0

http://docs.cython.org/src/userguide/wrapping_CPlusPlus.htmlで cython の例を実行しようとしました。 基本的に、Rectangle.h、Rectangle.cpp、setup.py、rect.pyx のコードをコピーしただけですpython setup.py build_ext --inplace を実行すると、エラーが発生します

running build_ext
building 'rect' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c rect.c -o build/temp.linux-x86_64-2.7/rect.o
In file included from rect.c:235:0:
Rectangle.h:1:1: error: unknown type name ‘namespace’
Rectangle.h:1:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
rect.c:236:15: fatal error: ios: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

私は何を間違っていますか???

4

2 に答える 2

2
于 2013-09-13T19:27:40.700 に答える
1

setup.py スクリプトで、言語を ext_modules の c++ に設定します。

...
ext_modules=[
    Extension("rect",
    sources=["rect.pyx"],
    language="c++",
    )]

setup(
  name = 'rect',
  ext_modules = cythonize(ext_modules),
)

Cython は正しい C++ コンパイラを呼び出すようになりました

于 2016-05-11T07:53:47.513 に答える