0

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
2
  • I deleted my answer because it doesn't work for you. In my PC I solved the problem using setup.py, so I cannot really track the problem anymore to try to help with it. Sorry if I wasted your time. Commented Mar 28, 2015 at 16:09
  • There is no wasted time, every constructive answer is a new step to the solution. Thank you for your help ! Commented Mar 29, 2015 at 6:57

2 Answers 2

2

Problem solved using the following commands :

cython3 test.pyx
gcc -I/usr/include/python3.4m test.c -lpython3.4m
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.