From: Daniel Berger Date: 2005-10-26T13:47:03+09:00 Subject: Re: mkmf, linking against a specific DLL on windows nobuyoshi nakada wrote: > Hi, > > At Wed, 26 Oct 2005 07:42:03 +0900, > Daniel Berger wrote in [ruby-talk:162622]: > > Ok, but you can generate a .lib file from a .def, and you can generate > > a .def from a .dll. Here's a script I cobbled together that did the > > trick: > > Of course you can, but I don't think it should be done > silently by mkmf.rb. It belongs to setting up of a particular > library, not building an extension for it. > > > # Create a .def file from the results of a 'link -dump -exports' > > Actually, it calls dumpbin.exe. My research indicates that older compilers use dumpbin.exe, but the more recent ones just use 'link -dump'. I don't have dumpbin.exe on my machine for example, but I do have link.exe. > > > # Create a .lib file from a .def file. Note that the lib command doesn't > > # seem to like long path names, so we'll shorten them. > > Really? > > $ lib -machine:x86 -def:../stable-build/i686-mswin32/msvcrt-ruby18.def -out:../stable-build/i686-mswin32/msvcrt-ruby18.lib > Microsoft (R) Library Manager Version 7.10.2240.8 > Copyright (C) Microsoft Corporation. All rights reserved. > > Creating library ../stable-build/i686-mswin32/msvcrt-ruby18.lib and object ../stable-build/i686-mswin32/msvcrt-ruby18.exp Perhaps it has something to do with the version of lib.exe I have at work, because I had to download it off the web. For whatever reason, the most recent versions of the free compiler from MS don't seem to include lib.exe by default any more. That, or I messed something up. I *do* have it on my older laptop, but not on my desktop, for example (which has a more recent version). Someone please correct me if I'm wrong, but I couldn't find it in any of the packages MS supplied. > It's possible to tweak win32/mkexports.rb to accept DLL files > as well as object files. Cool, but you're going to have to make a check to see if dumpbin exists and use link -dump instead if it doesn't. Regards, Dan