[Python-Dev] distutils, win32, multiple C extensions

Curt Hagenlocher curt at hagenlocher.org
Tue Apr 23 15:30:48 CEST 2013

Python-List (http://mail.python.org/mailman/listinfo/python-list) is the
better place for this kind of question; Python-Dev is for the development
of Python itself, not for development using Python.

When you built E1, it should have also built a ".lib" file in addition to
the ".pyd". It's the .lib that needs to be referenced when building E2. If
it did not, you may find this link helpful:

On Tue, Apr 23, 2013 at 4:18 AM, Emmanuel Bacry <
emmanuel.bacry at polytechnique.fr> wrote:

> Hello,
> I am a researcher in Applied Math.
> For my work I write a lot of code and right now I am moving to python.
> I am writing some C extensions (using swig).
> I wrote a first extension (a python module) which I'll call E1.
> I wrote a setup.py which works fine on all platforms.
> On Windows 7 it creates a library which is a .pyd file
> Now I want to write a second C extension E2 that is calling some functions
> of E1.
> The same kind of setup.py works fine on all platforms but Windows where it
> says (during the link) that the function sof E1 that are called by E2 are
> unreferenced.
> I am clearly not a Windows pro ... I am using mingw32 on Windows.
> Surfing the web, I understood that shared libraries work differently on
> windows than on other platforms. And that I should
> 1- export the symbols (i.e., the functions) of E1 when I build E1. In the
> distutils.Extension this seems to be done using
> argument export_symbols=[list of symbols to export]
> Now I have one problem : each time I specify in this list the name of a
> function in E1 it says that it doesn't know this symbol
> What am I doing wrong here, is there a special syntax ?
> 2- Now in the setup.py of E2 how do I declare that I want to use the E1
> shared lib.? Is the information on the exported symbol of E1 in the .pyd
> file or in the .def file ?
> I tried to specify the .pyd library in the arguments of the
> distutils.Extension .... but I have the feeling that's not the right thing
> to do (I have the feeling the .pyd is not the right file to point to)
> Not mentioning the problem specifying the path of the library with
> runtime_library_dirs ... which does not seem to work at all.
> Is there a simple way to do what  I want to do ?
> I did not find anything on the web explaining clearly what to do ...
> I am really really stuck
> I would appreciate any kind of help
> Emmanuel
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/curt%40hagenlocher.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130423/c1545b60/attachment.html>

More information about the Python-Dev mailing list