【发布时间】:2015-03-26 18:02:27
【问题描述】:
我正在尝试使用 GCC 将 Cython3 文件编译为可执行文件。 目前我仍然坚持简单的“hello world”:
# -*- coding: utf-8 -*-
if __name__ == "__main__":
print("Hello World !")
这是我为了编译这个简单的程序而尝试执行的命令:
cython3 test.pyx
gcc -I/usr/include/python3.4 test.c
第一个命令运行正确,但这是我输入第二个命令时得到的结果:
cython.c:422:14: error: conflicting types for ‘PyTypeObject’
typedef void PyTypeObject;
^
In file included from /usr/include/python3.4/pytime.h:6:0,
from /usr/include/python3.4/Python.h:65,
from cython.c:16:
/usr/include/python3.4/object.h:422:3: note: previous declaration of ‘PyTypeObject’ was here
} PyTypeObject;
^
cython.c: In function ‘__Pyx_PyObject_GetAttrStr’:
cython.c:488:18: warning: dereferencing ‘void *’ pointer
if (likely(tp->tp_getattro))
^
cython.c:399:43: note: in definition of macro ‘likely’
#define likely(x) __builtin_expect(!!(x), 1)
^
cython.c:488:18: error: request for member ‘tp_getattro’ in something not a structure or union
if (likely(tp->tp_getattro))
^
cython.c:399:43: note: in definition of macro ‘likely’
#define likely(x) __builtin_expect(!!(x), 1)
^
cython.c:489:18: warning: dereferencing ‘void *’ pointer
return tp->tp_getattro(obj, attr_name);
^
cython.c:489:18: error: request for member ‘tp_getattro’ in something not a structure or union
我目前正在 Debian 测试中运行,因此我有以下版本的 Python 和 Cython:
Python: 3.4.2-2
Cython: 0.21.1-1
【问题讨论】:
-
我删除了我的答案,因为它对你不起作用。在我的 PC 中,我使用 setup.py 解决了问题,因此我无法再真正跟踪问题以尝试解决问题。对不起,如果我浪费了你的时间。
-
没有浪费时间,每一个建设性的回答都是解决问题的一个新步骤。感谢您的帮助!