Creation of import libraries for Windows

Daniel Murphy yebblies at nospamgmail.com
Fri Jan 11 01:16:26 PST 2013


"Phil Lavoie" <maidenphil at hotmail.com> wrote in message 
news:cnfmacxdtgfmwmfzhfgm at forum.dlang.org...
> This websites recommends implib for the creation of import library 
> therefore I have been using it. When I compile + link my code containing 
> "extern( Windows )" function declarations, I get the following messages:
> Error 42: Symbol Undefined _functionName at ordinal (generic case)
> Error 42: Symbol Undefined _glGetIntegerv at 8 (just an example)
>
> Let's hypothesize that I am using "shared.dll" and I would like to 
> "statically" link against it using an import library. I use this command: 
> implib /noi /system shared.lib ..\shared.dll
> To generate the import library. Once done, I make sure the linker finds it 
> and rebuild the program. I get the same errors.
>

The leading underscore and @NNN are part of the extern(Windows) name 
mangling, aka STDCALL.  For some dll symbols are loaded via their export 
name, which is the unmangled name of the function.  The dll's export table 
does not know anything about the mangled name, or the calling convention or 
language used.

This is where import libraries come in - they provide a mapping from the 
mangled name to the exported symbol name the dll uses, as well as 
identifying which dll the symbol can be found in.

If you generate the import library from the dll, it uses the exported name 
because that's all it knows.

There are two ways forward:
1. define a def file to use with implib that gives the correct mangled name 
for each function
2. use coffimplib to convert an existing import library to omf

This thread might also be of use: 
http://forum.dlang.org/thread/hmapfdehxvvuuxswrtyb@forum.dlang.org 




More information about the Digitalmars-d mailing list