MakeLIB - utility to create (*.a) import library from DLL (source included)

Started by Paul Squires, June 02, 2015, 08:37:25 PM

Previous topic - Next topic

Paul Squires

Inspired by a utility that I saw that Marc Pons wrote last year, I decided to create a little program that reads a DLL and creates the corresponding FreeBASIC import library. In FB 32bit, those are the libraries that you will find in the \lib\win32 folder and have a format such as lib*.dll.a

MakeLIB takes as input a standard Windows DLL. It will create and shell to a batch file that invokes PEXPORTS.exe to create the export definitions (DEF) file and finally DLLTOOL.exe to create the *.a file. Simple.

You will need at least FireFly for FreeBASIC 3.74 (June 2, 2015) in order to compile the source code.

MakeLIB (32 bit exe and source files)   http://www.planetsquires.com/files/MakeLIB.rar


Paul Squires
PlanetSquires Software

Marc Pons


Paul Squires

Weird. There were already 10 or 15 downloads of the attachments but when I tried to download I kept getting a 404 file not found error. I repackaged the files into zip format rather than rar format and re-attached them to the original post. Hopefully it works okay now. I was able to download them.
Paul Squires
PlanetSquires Software

Richard Marchessault

I cannot download either of the zipped files. When I click on the link I get an error message that the file was not found.
Thanks,
Dick

Paul Squires

I don't know why this is happening. I deleted the attachments again and will upload them later. The forum software reports those two files as being in the database but missing for the folder. I will upload them to a folder on the PlanetSquires and then people can download it directly rather than having to go though the attachment process.
Paul Squires
PlanetSquires Software

Paul Squires

Okay, I have updated the original post to include download links rather than attachments.
Paul Squires
PlanetSquires Software

Rolf Brandt

Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Paul Squires

Hi Rolf - I have re-uploaded the two files again. Something is going on with the forum attachment system and/or my file save folder on the server. Very strange.
Paul Squires
PlanetSquires Software

Rolf Brandt

Thanks Paul,

now it worked.

I am very happy to see you are continuing further with FireFly. I am playing around with FreeBasic since yesterday. Looks quite promising. And the learning curve is not very steep.

The future is looking a little brighter again. I am sure many in the forum will be very happy about this.

Best wishes
Rolf
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Marc Pons

Hi Paul

I've just tested your Makelib utility , I've some comments

first it fails when trying to interface the user32.dll ( I always test whith this dll because its big and tricky)
it seems, its PEXPORTS.exe problem why ?

second point PEXPORTS produce DEF file without decoration part (mangled) even that decoration exists, the declare function must be inclosed by
Extern "windows-ms" Lib "xxx"  / End Extern       to be able to link
the normal "official" lib interfaces are most of them mangled and the .bi files propose
Extern "windows" Lib "xxx"   / End Extern

i've also reactived my first version , and post my reduced/simplified one at :
http://www.freebasic.net/forum/viewtopic.php?f=8&t=22882&p=208428#p208428

in case, some here interested...
Marc

Paul Squires

Not sure why, but PEXPORTS seems to GPF just after reading the SetWindowsHookW function in User32.dll. The batch file continues and dlltool creates the *.a library, albeit with an incomplete file list.

I am not sure how I feel about the mangled vs. non-mangled names. I need to research it more to satisfy myself of the pros and cons of each method.

Thanks!
Paul
Paul Squires
PlanetSquires Software

Jim Dunn

Just an FYI... can't download either the binary or the source rar files...
3.14159265358979323846264338327950
"Ok, yes... I like pie... um, I meant, pi."

Paul Squires

Updated the original post and uploaded new files. I tweaked the dlltool.exe command line slightly in the generated .bat file that creates the necessary lib file. I also switched from using pexports.exe to gendef.exe in order to generate the DEF listing from the DLL. I find gendef to be more reliable than pexports which tended to GPF on complicated DLL's.

Paul Squires
PlanetSquires Software

José Roca

Why your tool insist in creating the .def file in the folder where the .dll is located instead of the folder where the .a library will be created? If the folder where the -def file will be written is write protected, it will fail, and dlltool won't provide any meaningful message, driving you crazy.


@echo off
set path=%path%;C:\Users\Pepe\FreeBasic32\bin\win32\
gendef.exe "C:\Windows\SysWOW64\propsys.dll"
dlltool.exe -D "C:\Windows\SysWOW64\propsys.dll" -d "C:\Windows\SysWOW64\propsys.def" -l "C:\Users\Pepe\FreeBasic64\tools\makelib\libpropsys.dll.a"
[code]

José Roca

If anybody can make an import library for propsys.dll 32-bit that works I will be gratefully indebted.

I have made one, but the linker fails.