[Numpy-discussion] numpy.distutils, windows dll vs lib

David Cournapeau david at ar.media.kyoto-u.ac.jp
Fri Mar 16 00:51:48 EDT 2007


Robert Kern wrote:
> 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.
Sorry for the lack of details; I did this a long time ago, and the 
problem popped up for some people my package with windows (which I don't 
at all) just recently.

I don't use the library for linking: I only need to be able to load it 
dynamically through ctypes. What I did is simply overriding the 
calc_info method, in which I try to detect both library and header 
files. For the library, I do the following:

# Look for the shared library
sndfile_libs    = self.get_libs('sndfile_libs', self.libname)
lib_dirs        = self.get_lib_dirs()
for i in lib_dirs:
    tmp = self.check_libs(i, sndfile_libs)
    if tmp is not None:
        info    = tmp
        break
    else:
        return

When I look at the system_info.check_libs code, it looks like it is 
trying to look for any extension, and the first found is returned... But 
this is not what I get, and I am not sure to see what I am doing wrong.

cheers,

David



More information about the NumPy-Discussion mailing list