2

Trying to get cython to run and I get this issue after following the quick start guide:

$ ~/midt $ ./setup.py build_ext --inplace
running build_ext
building 'proc' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c proc.c -o build/temp.linux-x86_64-2.7/proc.o
proc.c:2511:16: error: ‘initproc’ redeclared as different kind of symbol
 PyMODINIT_FUNC initproc(void); /*proto*/
                ^
In file included from /usr/include/python2.7/Python.h:80:0,
                 from proc.c:16:
/usr/include/python2.7/object.h:320:15: note: previous declaration of ‘initproc’ was here
 typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
               ^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Here are my version numbers and stuff:

$ ~/midt $ python --version
Python 2.7.6
$ ~/midt $ cython --version
Cython version 0.23.5
$ ~/midt $ uname -a
Linux xxxxx 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

1 Answer 1

2

I believe the issue is:

  1. Python requires the function to initialise a C module initialisation to be called init<module_name> (where you substitute your module name). (Python 3 uses a slightly different form).

  2. You've called your module proc.

  3. Cython has thus created a function called initproc to be defined when your module is imported.

  4. Python defines a typedef called initproc internally, which conflicts with the Cython generated initproc used to initialise your module.

The solution is to call your module something other than proc. It isn't an ideal solution, but there aren't too many other options.


One of the reasons Python 3 picked a different form PyInit_<module_name> was that the Python 2 form was known to cause a few conflicts (see https://www.python.org/dev/peps/pep-3121/#entry-point-name-conflicts).

Sign up to request clarification or add additional context in comments.

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.