Creating C modules for Python under Cygwin
Jason Tishler
jason at tishler.net
Mon May 6 09:48:06 EDT 2002
Rick,
Please keep your replies on-list, so others can benefit too.
On Sun, May 05, 2002 at 09:04:28AM -0700, Rick Muller wrote:
> Jason, thanks for your reply.
You are welcome.
> Jason Tishler wrote:
> > On Sat, May 04, 2002 at 10:39:16AM -0700, Richard P. Muller wrote:
> > > I'm having trouble creating Python modules from C under Cygwin. The
> > > process works fine under Linux, but I get a long list of undefined
> > > references (to PyArg_ParseTuple, PyArg_BuildValue, etc.) when I try to
> > > link under Cygwin.
> >
> > Are you using the Cygwin Python that is part of the standard Cygwin
> > distribution? Or, one that you built yourself? The following assumes
> > the former.
>
> That's correct, I'm using the cygwin module you built.
>
> >
> > > I found a reference in an archive of a Cygwin mailing list that claims I
> > > have to satisfy all of the undefined references under Cygwin. But it
> > > seems silly to link in the entire Python library in a tiny little
> > > module.
> >
> > I don't believe that the above implies linking the "entire Python
> > library." Instead one just needs to link against the import library
> > that corresponds to the Cygwin Python DLL core. This is exactly how it
> > works for Win32 Python and other Windows DLLs too.
> >
>
> Great.
>
> > Yes, use Distutils to build your shared extension. If you use this
> > method, then the "right things" will happen automatically.
>
> I didn't realize that Distutils *could* build shared extensions. I'll
> read up on them.
>
> >
> > Otherwise, you need to do the following when building your shared
> > extension:
> >
> > 1. during compilation specify -DUSE_DL_IMPORT
> >
> > 2. during linking specify -L/usr/lib/python2.2/config -lpython2.2
> >
> > Jason
>
> Actually, I had to specify -L/usr/lib/python2.2/config -lpython2.2.dll.
> Does this mean I did something dumb?
Not dumb, but I don't understand the semantics of "-lpython2.2.dll".
With the current (and even not so recent) Cygwin binutils, the
"-lpython2.2" option means link with the first one of the following:
1. libpython2.2.dll.a
2. libpython2.2.a
found in the library search path.
What does "-lpython2.2.dll" mean? libpython2.2.dll.a? If so, then you
should use "-lpython2.2" instead. libpython2.2.dll? If so, then you
are linking directly against the DLL which should be avoided if the import
library is available (which it is).
> But in any case, it works beautifully now. Thanks very much for your
> help!
Good -- I'm glad that you solved your problem.
Jason
More information about the Python-list
mailing list