www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How are windows import library created

reply "Phil Lavoie" <maidenphil hotmail.com> writes:
Hi,

I am currently trying to create an import library for 
opengl32.dll. I used this command:
implib /noi /system ...
To create the import library. However, the exported symbols do 
not have the at suffix ( someInt) (supposed to be _stdcall, so 
translated to extern( Windows ), which expects  ... suffixes). 
How to I add those using implib? Or how are the import library 
for the compiler created (what tool + options)?

Thanks,
Phil
Jan 07 2013
parent reply "Phil Lavoie" <maidenphil hotmail.com> writes:
On Monday, 7 January 2013 at 16:48:02 UTC, Phil Lavoie wrote:
 Hi,

 I am currently trying to create an import library for 
 opengl32.dll. I used this command:
 implib /noi /system ...
 To create the import library. However, the exported symbols do 
 not have the at suffix ( someInt) (supposed to be _stdcall, so 
 translated to extern( Windows ), which expects  ... suffixes). 
 How to I add those using implib? Or how are the import library 
 for the compiler created (what tool + options)?

 Thanks,
 Phil
I am asking this because if I compare a handmade import library, for example kernel32.lib with the one provided with the compiler I can see that, in the hand made one, there are no visible ordinal expressions for none of the exported symbols, whereas you can find them in the one provided with the compiler. I'd like to know why is extern( Windows ) expecting an ordinal and how is this ordinal calculated? But this question is really just out of pure curiousity. A more practical question remains: how where the import library provided with dmd created? How can I recreate the final products, I would really like to link against opengl32.dll with an import library. Thank you, Phil
Jan 08 2013
parent reply "Phil Lavoie" <maidenphil hotmail.com> writes:
On Tuesday, 8 January 2013 at 16:57:51 UTC, Phil Lavoie wrote:
 On Monday, 7 January 2013 at 16:48:02 UTC, Phil Lavoie wrote:
 Hi,

 I am currently trying to create an import library for 
 opengl32.dll. I used this command:
 implib /noi /system ...
 To create the import library. However, the exported symbols do 
 not have the at suffix ( someInt) (supposed to be _stdcall, so 
 translated to extern( Windows ), which expects  ... suffixes). 
 How to I add those using implib? Or how are the import library 
 for the compiler created (what tool + options)?

 Thanks,
 Phil
I am asking this because if I compare a handmade import library, for example kernel32.lib with the one provided with the compiler I can see that, in the hand made one, there are no visible ordinal expressions for none of the exported symbols, whereas you can find them in the one provided with the compiler. I'd like to know why is extern( Windows ) expecting an ordinal and how is this ordinal calculated? But this question is really just out of pure curiousity. A more practical question remains: how where the import library provided with dmd created? How can I recreate the final products, I would really like to link against opengl32.dll with an import library. Thank you, Phil
Or is it strictly the linker that generate those? I am quite lost.
Jan 08 2013
parent "kiskami" <kiskami freemail.hu> writes:
Hi, im no expert in this, but my workflow used to be the 
following:
Windows (vc) lib conversion to a dmd linkable one:
1. def file generation, from windows lib: coffimplib.exe -e 
ecl.lib
2. edit def file for the missing symbols, for ex: _SDL_Init = 
SDL_Init ==> _SDL_Init 4 = SDL_Init
3. update lib: implib.exe SDL.lib SDL.def

In a recent project I only needed the 1. and 3. points, and to 
use extern (C), because the def file was ok!
Jan 10 2013