Reputation: 51
I'm trying to compile a Cython3 file into an executable using GCC. For the moment I'm still stuck with a simple "hello world" :
# -*- coding: utf-8 -*-
if __name__ == "__main__":
print("Hello World !")
Here is the command I've tried to execute in order to compile this simple program :
cython3 test.pyx
gcc -I/usr/include/python3.4 test.c
The first command run correctly, but here is what I get when I type the second one :
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
I'm currently running on Debian testing, and therefore I have the following versions of Python and Cython :
Python: 3.4.2-2
Cython: 0.21.1-1
Upvotes: 0
Views: 986
Reputation: 34316
I doubt your answer solves the problem.
Your original problem was, that the extension was called cython.pyx
(taking into account this post).
However, it is not allowed to name your cython-module "cython" because it is a special name for Cython and leads to a generated c-file which cannot be compiled (for whatever reason spurious typedef void PyTypeObject;
is inserted). Unluckily cython doesn't report an error for this case.
Renaming the pyx-file/extension from cython.pyx
to test.pyx
solved the issue.
Upvotes: 0
Reputation: 51
Problem solved using the following commands :
cython3 test.pyx
gcc -I/usr/include/python3.4m test.c -lpython3.4m
Upvotes: 2