[Numpy-discussion] numpy.distutils, windows dll vs lib
Robert Kern
robert.kern at gmail.com
Fri Mar 16 00:40:36 EDT 2007
David Cournapeau wrote:
> Hi,
>
> recently, I got some problems detecting a dynamic library (dll) with
> numpy.distutils. Basically, I have a package which uses a class derived
> from system_info from numpy.distutils to detect a dll I use through ctypes.
> If only the dll is present, my numpy.distutils.system_info derived
> class does not find the library; if the .lib is present too, then it is
> detected. Why is that ? Can I modify my class do detecting the dll is
> enough ? I don't know how windows dynamic linking and dynamically loaded
> libraries work, and I am kind of confused by this (I thought .lib was
> .a, and .dll was .so, and that symbols were not exported by default on
> windows contrary to Unix, but the difference seems more subtle than
> this....).
Generally, you don't use .dll files to link against. With MSVC, you need a .lib
file corresponding to your target .dll file which has the symbols. mingw and
cygwin use similar .a files. This information is coded in the
system_info.library_extensions() method, which you can override if you need
something different. Of course, since you don't mention what methods on
system_info that you are using, I can't quite be sure this will satisfy your needs.
Note that so_ext here is obtained from the distutils configuration for your
platform and is the file extension for extension modules, thus '.pyd' on
Windows, not '.dll'.
def library_extensions(self):
static_exts = ['.a']
if sys.platform == 'win32':
static_exts.append('.lib') # .lib is used by MSVC
if self.search_static_first:
exts = static_exts + [so_ext]
else:
exts = [so_ext] + static_exts
if sys.platform == 'cygwin':
exts.append('.dll.a')
if sys.platform == 'darwin':
exts.append('.dylib')
return exts
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list