Newbie question: COM programming and linking to Windows libraries

Sergey Gromov snake.scaly at gmail.com
Thu Mar 12 15:41:57 PDT 2009


Thu, 12 Mar 2009 17:12:41 -0400, Patrick Kristiansen wrote:

> The compiler fails with the following error:
> 
>      setwallp.obj(setwallp)
>       Error 42: Symbol Undefined _CoInitialize at 4
>      --- errorlevel 1

The implib doesn't produce acceptable results for Windows system DLLs.
It does create a library, but functions in that library are mangled
using either Pascal (default) or cdecl (/s switch) naming convention.
That is, either plain function name, or name with an underscore
prepended, respectively.

Windows uses stdcall convention.  Mangled names in this convention
include size of function arguments, the @4 part in your example.  The
information in DLL is insufficient to gather this sort of information so
implib can't help here even in theory.

If you have a COFF lib from SDK the best you can do is to use coffimplib
instead:

http://www.digitalmars.com/ctg/coffimplib.html

available from Digital Mars FTP:

ftp://ftp.digitalmars.com/

This tool converts a COFF library into an OMF one, preserving any
required information and immediately usable with DMD.


More information about the Digitalmars-d-learn mailing list