Converting Microsoft lib (.LIB) to FreeBASIC lib (.dll.a)

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Converting Microsoft lib (.LIB) to FreeBASIC lib (.dll.a)

Post by AGS »

When you download a software package consisting of one or more dynamic link libraries (extension .dll) it is not unlikely for the package to also contain

- include files (extension: .h)
- Microsoft import libraries (extension: .LIB)

If you're lucky there will be .dll.a files (=fb import libraries) in the package as well. But what if the package does not contain .dll.a files?

This is what you do.

First go to MingGW on sourceforge

and download binutils and mingw utils from sourceforge (make sure you get the binaries). Obviously you'll have to unpack the downloaded archives.

You need three programs to convert files with extension .LIB to files with extension .dll.a
- dlltool;
- as;
- reimp.

dlltools and as are in the binutils archive, reimp is in the mingw utils archive. reimp is the program that will do the actual conversion (reimp needs dlltool and as to do it's thing).

An example ('how to use reimp').

Suppose you have downloaded a Microsoft dll called iup.dll and the import library that comes with it (called iup.LIB). To turn iup.LIB into libiup.dll.a do the following.

Type

reimp iup.lib


at a commandline prompt.
(make sure dlltool, as and reimp are in the working directory or in the windows path).

The result of the execution of reimp iup.lib is a library called iup.a That's almost what is needed but not quite. FreeBASIC needs import libraries to start with the word 'lib' and end with the extension '.dll.a' you'll have to rename iup.a to libiup.dll.a

After you've renamed the file to libiup.dll.a and copied it to the map where the rest of the FreeBASIC libraries are (something like c:\program files\freebasic\lib\win32\) you can almost start using iup.dll/iup.dll.a

Almost because you'll still have to convert the appropriate header files to FreeBASIC (one of these header files will include the statement
#inclib "iup").

End of example, end of message. Enjoy using reimp.
jcfuller
Posts: 325
Joined: Sep 03, 2007 18:40

Post by jcfuller »

AGS
I'm not sure the version but I don't have reimp ?

James
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Post by srvaldez »

jcfuller
Posts: 325
Joined: Sep 03, 2007 18:40

Post by jcfuller »

Thank you gentlemen. This should be quite useful ( when I find the time to get back to Fb programming)

Jame
Landeel
Posts: 777
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Post by Landeel »

Very useful. Thank you.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

Yes, thanks for posting this. I have had MinGW on my system for years, and looked in the bin directory many times, but never noticed reimp.exe. I tested it on the pdf.lib from the PSDK and it worked correctly.
Kenny80
Posts: 21
Joined: Mar 31, 2008 8:02

Post by Kenny80 »

Strange thing is that i get a .dll file instead of .a i both tried reimp name.lib and reimp -c name.lib still get a dll hehe
integer
Posts: 409
Joined: Feb 01, 2007 16:54
Location: usa

Post by integer »

AGS & srvaldez
Thank you both.
Good to know.
cha0s
Site Admin
Posts: 5319
Joined: May 27, 2005 6:42
Location: USA
Contact:

Post by cha0s »

Thanks for the great post!
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Post by sir_mud »

Kenny80 wrote:Strange thing is that i get a .dll file instead of .a i both tried reimp name.lib and reimp -c name.lib still get a dll hehe
By default Windows (stupidly) hides the extension so "libIUP.dll.a" would show in Explorer as "libIUP.dll".

Windows XP (2k and 9x are similiar to this):
http://www.wikihow.com/Disable-Hidden-F ... Windows-XP

Vista and 7:
http://vistasupport.mvps.org/disable_hi ... types.html
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Post by Galeon »

I have gcc 3.4.5 in my WinXPSP2, I tried this:
reimp htmlhelp.lib
But I got a file "init.obj".
htmlhelp.lib is from HTML Help Workshop
I think, but not sure, is that according to Microsoft, there is something special inside it because it loads the library automatically.
Amundo
Posts: 57
Joined: Feb 26, 2007 0:25

Post by Amundo »

Thanks AGS, this is a much better explanation than my attempt :(

http://www.freebasic.net/forum/viewtopi ... highlight=
Post Reply