PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: MakeLIB - utility to create (*.a) import library from DLL (source included)  (Read 8316 times)

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software

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


« Last Edit: August 15, 2015, 11:38:22 AM by TechSupport »
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Marc Pons

  • Junior Member
  • **
  • Posts: 141
  • FF3 User

Hi Paul

The attachments do not work!
Please Check.
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Richard Marchessault

  • Junior Member
  • **
  • Posts: 185

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.
Logged
Thanks,
Dick

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software

Okay, I have updated the original post to include download links rather than attachments.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Rolf Brandt

  • Master Member
  • ****
  • Posts: 933
  • XP Pro SP3 - Vista - Win7
    • Taxi Dispatching Systems

Hi Paul,

the links seem not to work either.

Rolf
Logged
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

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software

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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Rolf Brandt

  • Master Member
  • ****
  • Posts: 933
  • XP Pro SP3 - Vista - Win7
    • Taxi Dispatching Systems

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
Logged
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

  • Junior Member
  • **
  • Posts: 141
  • FF3 User

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
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software

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
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Jim Dunn

  • Junior Member
  • **
  • Posts: 111
  • Jim Dunn

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

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software

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.

« Last Edit: August 15, 2015, 11:59:34 AM by TechSupport »
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

  • Guru Member
  • *****
  • Posts: 3205

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.

Code: [Select]
@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

  • Guru Member
  • *****
  • Posts: 3205

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.
Pages: [1] 2