[Distutils] Distuils MSVC link failure between libraries

Chris Barker - NOAA Federal chris.barker at noaa.gov
Tue Aug 15 11:42:53 EDT 2017


I'm trying to create multiple C++ extensions that have dependencies between
them.

This works fine on Linux with gcc, but I get link failures on Windows with
MSVC due to this
<https://github.com/python/cpython/blob/master/Lib/distutils/_msvccompiler.py#L467>


Is that the only issue? MSVC and FCC linking is pretty different-- I know I
tried to do something like this (a few years ago) and it didn't work -- I
think because the symbols I needed weren't exported, or something like that.

If precompiled extensions are to be published with MSVC and expected to be
linked against (maybe this is not recommended?)


Indeed, it is not recommended-- onhe passive sense -- I.e. the system isn't
designed to support that.

IIUC, while extension modules are dlls, they are specifically designed to
be called from cpython, not as general purpose libraries to be called from
other C code.

The solution is to build a dill with all the C/C++ code you need, and then
have all your modules link against that dll.

Proof of concept
<https://github.com/0xz/distutils_msvc/blob/master/setup.py>


If that works, and doesn't cause other problems, (I am not qualified to
assess that), it could be handy. There are times I would have liked
distutils to be able to build a dll for me that could be used by other
modules.

-CHB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20170815/077b04b2/attachment.html>


More information about the Distutils-SIG mailing list