T
TPJ
I'm trying to get a wrapper for my C code in order to be able to use it
as a module in Python. I'm doing it as follows:
C code (file_c.c):
-------------------------------
#include <stdio.h>
void hello( int size )
{
printf("Hello! %d\n", size);
}
-------------------------------
Pyrex code (file.pyx):
-------------------------------
cdef extern void hello( int size )
-------------------------------
Python code (setup.py):
-------------------------------
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
setup(
name = "File",
ext_modules=[
Extension( "file", ["file.pyx", "file_c.c"] )
],
cmdclass = { 'build_ext': build_ext }
)
-------------------------------
After
$ python setup.py build_ext --inplace
all is compiled ok, but the shared library (file.so) is built only from
one file (file_c.o) - and the second object file (file.o) is ignored.
Of course it's imposible to import such a module in Python.
What am I doing wrong?
as a module in Python. I'm doing it as follows:
C code (file_c.c):
-------------------------------
#include <stdio.h>
void hello( int size )
{
printf("Hello! %d\n", size);
}
-------------------------------
Pyrex code (file.pyx):
-------------------------------
cdef extern void hello( int size )
-------------------------------
Python code (setup.py):
-------------------------------
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
setup(
name = "File",
ext_modules=[
Extension( "file", ["file.pyx", "file_c.c"] )
],
cmdclass = { 'build_ext': build_ext }
)
-------------------------------
After
$ python setup.py build_ext --inplace
all is compiled ok, but the shared library (file.so) is built only from
one file (file_c.o) - and the second object file (file.o) is ignored.
Of course it's imposible to import such a module in Python.
What am I doing wrong?