impdef, msvc++ 6, and GMP
Ike Evans
ike at evheuristics.com
Fri Nov 7 09:10:54 CET 2003
On 7 Nov 2003 at 12:20, Sisyphus wrote:
>
> It's just so much nicer and easier if people can simply take the dll and
> build the lib using only msvc++, without having to use any other tool. Of
> course, they already can do that ... if they've got a 'proper' edition of
> msvc++ 6 :-)
>
Actually, the 'proper' edition of msvc++ 6 doesn't help. The ms knowledge
base doesn't even mention impdef, but if you run a search using just the
right terms on a night of a full moon after praying to your favorite
search engine god you can find knowledge base article 131313 (or, having
read this post, just search for 131313) which says "There is no 32-bit
utility that can create an import library from a .DLL, as there was with
16-bit versions of Visual C++."
131313 describes two workarounds that aren't guaranteed to work. The
first workaround (hand-building the .def) does work in this case. I
didn't try the second workaround (building a stub for every gmp
function).
Here's my version of the process, which may help avoid some pitfalls for
the unwary. YMMV.
1. Use 'DUMPBIN /EXPORTS libgmp-3.dll' to get a symbol list. Redirect to
some convenient text file.
1.1. If this is the first time you've used an MSVC++ 6 command line tool
in awhile, you'll probably need to set up your environment properly. Use
ms provided Vcvars32.bat to do this (found in the Vc98/bin directory).
1.1.1. If you are running from an ms-dos prompt and run out of
environment space, increase same by maxing out initial environment space
in the properties:memory dialog for your ms-dos prompt.
2. Handbuild libgmp-3.def with the symbol list from step 1.
2.1. libgmp-3.def is a text file that looks like:
LIBRARY libgmp-3
EXPORTS
__gmp_0
__gmp_allocate_func
.....
2.1.1. If your goal is to do this with only ms provided tools, you can
easily extract just the 382 symbols from the output of step 1 by
importing into excel.
3. Use 'LIB /DEF:libgmp-3.def /OUT:libgmp-3.lib' to create your lib.
4. Put .lib and .dll in appropriate places and add libgmp-3.lib to your
link list in msvc++ 6 project settings.
I did this successfully using deltatrinity's gmp build (thanks Eric).
BTW, you could avoid having to build a .lib in the first place by using
run-time dynamic linking to the .dll, but that has a different set of
hassles.
Ike
More information about the gmp-discuss
mailing list