我一直在用 cython 编写一些 python 扩展模块。我编写的扩展构建并运行良好。然后,我想在访问我的 numpy 数组时使用类型化的 memoryviews,因为它们似乎有几个优点http://docs.cython.org/src/userguide/memoryviews.html
但是,一旦我在我的 cython 代码中使用 memoryview,我就会在构建扩展时遇到错误。例如,如果我添加此测试行:
cdef double[:, ::1] X = np.zeros((100, 100))
到现有的工作 cython 扩展。我会收到以下错误:
C:\MinGW\bin\gcc.exe -shared -s build\temp.win32-2.7\Release\image_box.o build\temp.win32-2.7\Release\image_box.def -Lc:\python27\libs -Lc:\python27\PCbuild -lp
ython27 -lmsvcr90 -o x:\ARframework\python\image_ops\image_box.pyd
build\temp.win32-2.7\Release\image_box.o:image_box.c:(.text+0xe23): undefined reference to `___sync_fetch_and_add_4'
build\temp.win32-2.7\Release\image_box.o:image_box.c:(.text+0x3318): undefined reference to `___sync_fetch_and_add_4'
build\temp.win32-2.7\Release\image_box.o:image_box.c:(.text+0x4c81): undefined reference to `___sync_fetch_and_sub_4'
build\temp.win32-2.7\Release\image_box.o:image_box.c:(.text+0x4d37): undefined reference to `___sync_fetch_and_sub_4'
build\temp.win32-2.7\Release\image_box.o:image_box.c:(.text+0x10767): undefined reference to `___sync_fetch_and_sub_4'
build\temp.win32-2.7\Release\image_box.o:image_box.c:(.text+0x10793): undefined reference to `___sync_fetch_and_sub_4'
collect2.exe: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
我已尝试将 -march=i486 添加到 gcc 行,如本文所述: undefined reference to sync_fetch_and_add_4 但这并没有解决问题。就此而言,我还尝试了 -march=i586 和 -march=pentium ,但均未成功。
知道这里发生了什么吗?
我的平台是Windows 7,mingw版本是4.70,Cython版本是0.17.1
谢谢