Linking against a Win32-DLL

Bill Baxter dnewsgroup at billbaxter.com
Sun Jul 8 13:37:29 PDT 2007


Marc Müller wrote:
> Hello,
> 
> as my first Project in D I am going to write a Application for my Wacom 
> graphic tablet.
> 
> So i have to use a windows dll(wintab32.dll) - but i don't have a 
> corresponding lib-file.
> 
> I have converted the C-Header I found with the dev-kit of my graphic 
> tablet and converted it to D.
> 
> I tried to use the "export(C)" or the "export(Windows)" settings in the 
> converted header file.
> 
> Example from the converted header -> wintab.d:
> extern(Windows)
> {
>     UINT  WTInfoA(UINT , UINT , LPVOID );
> }
> 
> 
> 
> demo.d:
> import std.stdio;
> import wintab;
> 
> void main(char[][] args)
> {
>     writefln("Hello World\n");
>     WTInfo( 0, 0, null);
> }
> 
> 
> 
> When i compile my Hello-World Application which is calling a function 
> from the DLL i get the following errormessages from the compiler (using 
> "extern (C)"):
> 
> 
> dmd.exe demo.d -LC:/WINDOWS/system32/wintab32.dll
> d:\Projects\wacom\dmd\bin\..\..\dm\bin\link.exe 
> demo,,,user32+kernel32/noiC:/WINDOWS/system32/wintab32.dll;
> OPTLINK (R) for Win32  Release 7.50B1
> Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
> 
> OPTLINK : Warning 9: Unknown Option : NOIC
> OPTLINK : Warning 9: Unknown Option : WINDOWS
> OPTLINK : Warning 9: Unknown Option : SYSTEM32
> OPTLINK : Warning 9: Unknown Option : WINTAB32.DLL
> demo.obj(demo)
>  Error 42: Symbol Undefined _WTInfoA at 12
> 
> 
> 
> With "extern(Windows)" the last line reads:
>  Error 42: Symbol Undefined _WTInfoA
> 
> 
> I don't know what to do - and I can not find usefull information for 
> using Win32-DLLs without a lib-file.
> Are my compile settings correct?
> Is the converted header correct?
> Or is it just not possible using a DLL without a library?
> 
> Please give me a hint
> 
> Thanks
>     -Marc-


That's great.  I hope you'll be releasing this when you get it working. 
  I wrote a wintab wrapper for C++ that I'd like to port to D some day.
   http://www.billbaxter.com/projects/bbtablet

As torhu said, you can create a D-compatible import lib from the DLL 
with implib from the "BUP" ... although the command should be:
    implib /s wintab32.dll wintab32.lib
And I like to name the dmd-specific import libs something like 
wintab32_dmd.lib just so I know it's not a normal Microsoft import lib.

--bb



More information about the Digitalmars-d mailing list