Module definition file to MS COFF import library converter

Started by Vortex, December 21, 2006, 09:29:26 PM

Previous topic - Next topic

Vortex

Hi friends,

Here is my tool def2lib converting module definition files to MS COFF import libraries. The tool can emit libraries with undecorated function names :

Module definition file to MS COFF import library converter
Type II - Version 1.0 by Vortex

Usage    : def2lib deffile.def [optional]
Optional : -nod  no decoration in exported symbols


All exported symbols should be enclosed between dobule quotes :

"_keybd_event@16"
"_mouse_event@20"
"wsprintfA"
"wsprintfW"
"_wvsprintfA@12"

http://vortex.masmcode.com/files/def2lib10.zip

Shantanu Gadgil

Hello Vortex,
Excellent set of tools def2inc, dll2inc, def2lib, et al.

Recently I used all these to make me'self an "inc" and and import library file from a dll.

I used POLIB to make the def file; it makes the function names with the double quotes.

As long as I am linking using POLINK (in ASM) everything's fine, but if I wanted to use the import library with VC (2005) it would keep complaining that function not found. When I then removed the double quoted from the def file and then made the import library, it worked OK!

Just to be sure that I did everything correct:
1. Use POLIB to get the DEF file (parameter /MAKEDEF file)
2. Use DEF2LIB (or DEF2INC and then INC2LIB) to get import library.
*** remove double quotes from function names and use LIB.EXE to make the import library for use with VC 2005

Would this be the correct procedure?

Cheers,
Shantanu
To ret is human, to jmp divine!

Vortex

Hi Shantanu,

Thanks for your kind words. You can use my lib2def tool to extract def files from import libraries. It outputs symbols enclosed between double quotes like polib /MAKEDEF. You must not remove the double quotes from def files if you wish to convert them to libraries with def2lib. Inserting double quotes is a standard of Pelle's tools and I adopted it.

You can follow this procedure :

1. Use lib2def or polib with /MAKEDEF to extract the def file
2. Edit the def file to meet your requirements.
3. Use def2lib to create the import library.

You can get lib2def V2.0 from :

http://www.masm32.com/board/index.php?topic=4850.msg41901#msg41901

Shantanu Gadgil

OK, sorry about that...my "source" for me was a .dll file, so it started with dll2inc for me!

The double quotes were OK as long as I was using the outputs (INC and LIB) in my ASM projects.

The problem was when I tried to use the .LIB in my VC project, so I thought maybe VC wants a .LIB made by using its own LIB.EXE  ::) ::) and so I tried that, but no luck, and so I removed the double quotes while making the LIB to bed used with VC 2005.
(Of course, I had to make the .h file by hand, from the .inc file  :( :( )

I just wanted to ask if you too have seen this "double quote" behaviour of VC 2005. Have you ?

Cheers and thanks,
Shantanu
To ret is human, to jmp divine!

Vortex

It's true that you should remove the double quotes for lib.exe. The C/C++ compiler is not interested in the import libraries as it's the job of the linker to deal with the import libraries. Attached is an example of using libraries produced by def2lib with VC++ 2005 Express.

You should edit SetVars.bat depending on the installation directories of VC++ 2005 Express and PSDK.

[attachment deleted by admin]

Shantanu Gadgil

Hi Vortex,
OK!  :U :U Got it!  :U

The example you have shown compiles using the C/C++ compiler and links using POLINK. I had created the def/inc/h from an _existing_ dll and also I am using the IDE (VC++ 2005 Express).

I presume the linker would be hard-coded as LINK.EXE when using the IDE (or maybe some setting file somewhere), its just that while using Microsoft tools (compiler/linker/res compiler) its just mentally easier if I used a separate set import libraries than the ones created PO tools. It kinda helps to know if something doesn't work, that its my code thats the problem, and then there's not a lingering doubt that "maybe it has something to do with the library"  :red :bg

Cheers and thanks,
Shantanu
To ret is human, to jmp divine!

Vortex

Version 1.1
=======

- Corrected some minor bugs to support the Open Watcom linker JWLink maintained by Japheth

You can download JWlink from :

http://japheth.de/Download/jwlink18.ZIP