Python and Swig

Elie Naulleau Elie.Naulleau at westgroup.com
Thu Sep 23 16:12:16 EDT 1999


The answer is the following:

ld -G stemmer.o stemmer_wrap.o -o stemmermodule.so

Elie Naulleau wrote:

> I am experiencing some linking problems.
> I am using Python. I need to incorporate C functions
> accessible from Python. To do this I am using swig (www.swig.org).
> If I follow the steps advised by the documentation, everything is fine
> till
> the linking stage:
>
> swig -python stemmer.i
> OK
> gcc -c stemmer.c stemmer_wrap.c -I/csr0/gnu/lib/python1.5/config
> -I/csr0/gnu/include/python1.5/
> OK
> ld -shared stemmer.o stemmer_wrap.o -o stemmermodule.so
> error
>
> -shared in not recognized by Solaris linker, it is likely to be -d y
> So I do it again:
>
> ld -d y stemmer.o stemmer_wrap.o -o stemmermodule.so
> Undefined                       first referenced
>  symbol                             in file
> Py_InitModule4                      stemmer_wrap.o
> PyExc_TypeError                     stemmer_wrap.o
> exit                                stemmer_wrap.o
> tolower                             stemmer.o
> malloc                              stemmer_wrap.o
> sprintf                             stemmer_wrap.o
> PyString_FromString                 stemmer_wrap.o
> PyType_Type                         stemmer_wrap.o
> .umul                               stemmer.o
> .urem                               stemmer.o
> .rem                                stemmer.o
> Py_BuildValue                       stemmer_wrap.o
> PyErr_Occurred                      stemmer_wrap.o
> PyString_AsString                   stemmer_wrap.o
> sscanf                              stemmer.o
> PyModule_GetDict                    stemmer_wrap.o
> qsort                               stemmer_wrap.o
> fclose                              stemmer.o
> _Py_NoneStruct                      stemmer_wrap.o
> strncat                             stemmer_wrap.o
> PyArg_ParseTuple                    stemmer_wrap.o
> PyErr_SetString                     stemmer_wrap.o
> strncmp                             stemmer_wrap.o
> printf                              stemmer.o
> __iob                               stemmer_wrap.o
> PyDict_SetItemString                stemmer_wrap.o
> realloc                             stemmer_wrap.o
> free                                stemmer_wrap.o
> strcmp                              stemmer.o
> fgets                               stemmer.o
> fopen                               stemmer.o
> strcpy                              stemmer.o
> PyInt_FromLong                      stemmer_wrap.o
> strlen                              stemmer.o
> PyExc_NameError                     stemmer_wrap.o
> PyInt_AsLong                        stemmer_wrap.o
> fprintf                             stemmer_wrap.o
> ld: fatal: Symbol referencing errors. No output written to
> stemmermodule.so
>
> I running Solaris 2.5, gnu compiler, Sun solaris ld
> Reading ld man page did not help. Neither compiling object files with
> gcc -shared
> Any help ?
>
> Thanks
>
> Elie Naulleau
> Elie.Naulleau at westgroup.com





More information about the Python-list mailing list