swig and init_module or initmodule, windows XP
Thomas Jung
jung-paz at t-online.de
Tue Jun 17 12:05:16 EDT 2003
"Thomas Heller" <theller at python.net> schrieb im Newsbeitrag
news:n0ggk8mw.fsf at python.net...
> [Please don't top-post. I've rearranged the following to compensate...]
>
> "Thomas Jung" <jung-paz at t-online.de> writes:
>
> > "Thomas Heller" <theller at python.net> schrieb im Newsbeitrag
> > news:smq8kb99.fsf at python.net...
>
> >> "Jung-Paz" <jung-paz at t-online.de> writes:
> >>
> >> > I am using Python2.2, mingw and Swig 1.3.19, Windows XP, and trying
> >> > to build a module using the distutils.
>
> >> > Basically it works, but in the final linking step I get an
> >> > undefined reference to "initexample" (the module name is example).
>
> >> > This sounds reasonable, as the file example_wrap.c, as produced by
> >> > swig, contains only a function "init_example.c". If I replace
> >> > "init_example" by hand with "initexample" and compile and link by
> >> > hand, everything is fine, and I get a loadable and usable module.
> >> > Any idea how I could make swig to produce other function names, or
> >> > whatever could help ?
> >>
> >> Sounds like you should name your extension _example.pyd instead of
> >> example.pyd...
> >>
> >
> > But: I could rename it once I have it - however, unless I change that
> > "init_example" to "initexample" by hand, it dies in the linking step
with a
> > unresolved reference to initexample ...
> >
> Can you post the setup script you use?
>
> Thomas
Here is setup.py:
========================================================================
# setup.py
import distutils
from distutils.core import setup, Extension
setup(name = "Simple example from swig website", version = "2.2",ext_modules
= [Extension("example",["example.i","example.c"])])
========================================================================
and example.c (from the SWIG tutorial):
=========================================================================
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
int my_mod(int x, int y) {
return (x%y);
}
char *get_time() {
time_t ltime;
time(<ime);
return ctime(<ime);
}
===========================================================================
and example.i:
===========================================================================
/* example.i */
%module example
%{
/* Put header files here (optional) */
%}
extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
============================================================================
I call then "python setup.py build_ext -cmingw32 (or -ccygwin, when I try
that with cygwin)
I just had a look at SWIG-1.3.19/Source/Modules/python.cxx, there is a line
which changes module to _module, IF shadow classing is enabled.
However, I did not do that, at least not intentionally ...
Again, thank you very much ...
(BTW: what is top-posting ? How did I possibly do that ? I am sitting in
front of a windows machine, using outlook, and not really familiar with
windows. My family is forcing me now to use this :-)
More information about the Python-list
mailing list