首页 > 解决方案 > Cython 教程编译失败 [OSX]

问题描述

我尝试按照 cython 的教程进行操作。

在制作 hello.pyx/setup.py 文件后,我执行它进行编译

$ python setup.py build_ext --inplace

但我得到的是这样的。

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:220:5: error: 'TARGET_OS_EMBEDDED' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_EMBEDDE

.
.
.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:181:5: error: 'TARGET_OS_E
MBEDDED' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_EMBEDDED
    ^
.
.
.
194 warnings and 2 errors generated.
error: command 'clang' failed with exit status 1

因为错误/警告消息很长。我贴了一部分。

标签: compiler-errorscython

解决方案


它对我有用!

$ export CC=gcc
$ python setup.py build_ext --inplace
# success!

环境价值是重点。


推荐阅读