Qbasicnews.com

Full Version: How to make a library if i have a working dll
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

If i have a working inpout32.dll and a corresponding definition file can someone tell me how to make a library and how to use it?
(You can get the dll from http://www.logix4u.net/)

Contents of definition file inpout32drv.def:
LIBRARY INPOUT32

EXPORTS

Inp32 @1
Out32 @2

How to make a lib file (how shall i name it) and how to use it?

Do i have to make a .bi file?
If so what are the contents of this file?

Maybe this?

inpout32.bi:
Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)

Need some help!

Thanx
Here's your .a file, put it in lib/win32:
http://www.betterwebber.com/stuff/libinpout32.dll.a

then throw this at the top of your program:
Code:
Declare Function Inp32 Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Declare Sub Out32 Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal data As Integer)

And then you will be finished. I need to leave, so if you're still interested in learning how to use dlltools, it'll have to wait for a bit.
To make a libxxx.dll.a from a dll you need to get a couple of tools from the Mingw (or Dev-C) C compiler, pexports.exe and dlltool.exe
Pexports retrieves the exports file from the dll and dlltool makes the .a library.

Nekrophidius once did a batch file to automatize the process:

Code:
makea.bat
''makes an .a lib file from a dll
''by Nek
'This is a collection of files necessary to make .a files from dlls to which you don't have
'the .def file for. The two executables are part of the standard MinGW distribution. I wrote
'the batch file. To use this, place all the files in your FreeBASIC \bin directory. Copy
'your dll to the FreeBASIC \bin directory, and use <b>makea dllname</b> from the FreeBASIC
'\bin directory. Make sure you don't use the extension or the batch file will fail. If there
'are no errors reported, you'll find the .a file in your FreeBASIC \lib directory, ready to
'be used. Needs pexports.exe and dlltool.exe from mingw



@echo off
pexports -o %~n1.dll >%1.def
dlltool --def %~n1.def --dllname %~n1.dll --output-lib lib%~n1.dll.a
move lib~n%1.dll.a ..\lib
del %~n1.def