Thread overview
DMD's kernel32.lib missing symbols?
Jul 29, 2011
simendsjo
Jul 29, 2011
Simon
Jul 29, 2011
simendsjo
Jul 29, 2011
Simon
Jul 30, 2011
simendsjo
Jul 30, 2011
torhu
Jul 31, 2011
simendsjo
Jul 31, 2011
simendsjo
Jul 31, 2011
simendsjo
July 29, 2011
Not sure how I can search for symbols in the library, but it seems the library is missing functions.
I've tried using coffimplib on kernel32.lib from the Windows SDK, but it neither produces a new library or give me an error.

What Windows version is the library based on?
How can I check what symbols exists?
Is there a way to convert WinSDK's library to omf?
July 29, 2011
On 29/07/2011 11:14, simendsjo wrote:
> Not sure how I can search for symbols in the library, but it seems the
> library is missing functions.
> I've tried using coffimplib on kernel32.lib from the Windows SDK, but it
> neither produces a new library or give me an error.
>
> What Windows version is the library based on?
> How can I check what symbols exists?
> Is there a way to convert WinSDK's library to omf?

Shows how to make your own import lib for windows system dll:

http://www.sstk.co.uk/d.php

Been ages since I did that though so let me know if you have problems.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
July 29, 2011
On 29.07.2011 19:13, Simon wrote:
> On 29/07/2011 11:14, simendsjo wrote:
>> Not sure how I can search for symbols in the library, but it seems the
>> library is missing functions.
>> I've tried using coffimplib on kernel32.lib from the Windows SDK, but it
>> neither produces a new library or give me an error.
>>
>> What Windows version is the library based on?
>> How can I check what symbols exists?
>> Is there a way to convert WinSDK's library to omf?
>
> Shows how to make your own import lib for windows system dll:
>
> http://www.sstk.co.uk/d.php
>
> Been ages since I did that though so let me know if you have problems.
>

I've tried using implib too, but replacing dmd's own kernel32.lib seems to create problems.
July 29, 2011
On 29/07/2011 19:27, simendsjo wrote:
> On 29.07.2011 19:13, Simon wrote:
>> On 29/07/2011 11:14, simendsjo wrote:
>>> Not sure how I can search for symbols in the library, but it seems the
>>> library is missing functions.
>>> I've tried using coffimplib on kernel32.lib from the Windows SDK, but it
>>> neither produces a new library or give me an error.
>>>
>>> What Windows version is the library based on?
>>> How can I check what symbols exists?
>>> Is there a way to convert WinSDK's library to omf?
>>
>> Shows how to make your own import lib for windows system dll:
>>
>> http://www.sstk.co.uk/d.php
>>
>> Been ages since I did that though so let me know if you have problems.
>>
>
> I've tried using implib too, but replacing dmd's own kernel32.lib seems
> to create problems.

What sort of problems? It's worked perfectly for me so far.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
July 30, 2011
On 29.07.2011 22:06, Simon wrote:
> On 29/07/2011 19:27, simendsjo wrote:
>> On 29.07.2011 19:13, Simon wrote:
>>> On 29/07/2011 11:14, simendsjo wrote:
>>>> Not sure how I can search for symbols in the library, but it seems the
>>>> library is missing functions.
>>>> I've tried using coffimplib on kernel32.lib from the Windows SDK,
>>>> but it
>>>> neither produces a new library or give me an error.
>>>>
>>>> What Windows version is the library based on?
>>>> How can I check what symbols exists?
>>>> Is there a way to convert WinSDK's library to omf?
>>>
>>> Shows how to make your own import lib for windows system dll:
>>>
>>> http://www.sstk.co.uk/d.php
>>>
>>> Been ages since I did that though so let me know if you have problems.
>>>
>>
>> I've tried using implib too, but replacing dmd's own kernel32.lib seems
>> to create problems.
>
> What sort of problems? It's worked perfectly for me so far.
>

PTLINK (R) for Win32  Release 8.00.12
opyright (C) Digital Mars 1989-2010  All rights reserved.
ttp://www.digitalmars.com/ctg/optlink.html
:\dmd\windows\bin\..\lib\phobos.lib(dmain2)
Error 42: Symbol Undefined _LocalFree@4
:\dmd\windows\bin\..\lib\phobos.lib(dmain2)
Error 42: Symbol Undefined _WideCharToMultiByte@32

etc..

I tried to replace kernel32.lib like this:
c:\dmd\windows\lib>implib /system kernel32.lib \Windows\system32\kernel32.dll

As this didn't work, I recompiled druntime and phobos with the new kernel32.lib, but I get the same errors.
July 30, 2011
On 30.07.2011 11:43, simendsjo wrote:
> On 29.07.2011 22:06, Simon wrote:
>>  On 29/07/2011 19:27, simendsjo wrote:
>>>  On 29.07.2011 19:13, Simon wrote:
>>>>  On 29/07/2011 11:14, simendsjo wrote:
>>>>>  Not sure how I can search for symbols in the library, but it seems the
>>>>>  library is missing functions.
>>>>>  I've tried using coffimplib on kernel32.lib from the Windows SDK,
>>>>>  but it
>>>>>  neither produces a new library or give me an error.
>>>>>
>>>>>  What Windows version is the library based on?
>>>>>  How can I check what symbols exists?
>>>>>  Is there a way to convert WinSDK's library to omf?
>>>>
>>>>  Shows how to make your own import lib for windows system dll:
>>>>
>>>>  http://www.sstk.co.uk/d.php
>>>>
>>>>  Been ages since I did that though so let me know if you have problems.
>>>>
>>>
>>>  I've tried using implib too, but replacing dmd's own kernel32.lib seems
>>>  to create problems.
>>
>>  What sort of problems? It's worked perfectly for me so far.
>>
>
> PTLINK (R) for Win32  Release 8.00.12
> opyright (C) Digital Mars 1989-2010  All rights reserved.
> ttp://www.digitalmars.com/ctg/optlink.html
> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
> Error 42: Symbol Undefined _LocalFree@4
> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
> Error 42: Symbol Undefined _WideCharToMultiByte@32
>
> etc..
>
> I tried to replace kernel32.lib like this:
> c:\dmd\windows\lib>implib /system kernel32.lib
> \Windows\system32\kernel32.dll
>
> As this didn't work, I recompiled druntime and phobos with the new
> kernel32.lib, but I get the same errors.

Both those symbols are definitely present in the kernel32.lib that comes with DMD 2.053.  Just grep for them and you'll see.  There is something going on with either your DMD install or the command line passed to the linker.
July 31, 2011
On 30.07.2011 16:30, torhu wrote:
> On 30.07.2011 11:43, simendsjo wrote:
>> On 29.07.2011 22:06, Simon wrote:
>>> On 29/07/2011 19:27, simendsjo wrote:
>>>> On 29.07.2011 19:13, Simon wrote:
>>>>> On 29/07/2011 11:14, simendsjo wrote:
>>>>>> Not sure how I can search for symbols in the library, but it seems
>>>>>> the
>>>>>> library is missing functions.
>>>>>> I've tried using coffimplib on kernel32.lib from the Windows SDK,
>>>>>> but it
>>>>>> neither produces a new library or give me an error.
>>>>>>
>>>>>> What Windows version is the library based on?
>>>>>> How can I check what symbols exists?
>>>>>> Is there a way to convert WinSDK's library to omf?
>>>>>
>>>>> Shows how to make your own import lib for windows system dll:
>>>>>
>>>>> http://www.sstk.co.uk/d.php
>>>>>
>>>>> Been ages since I did that though so let me know if you have problems.
>>>>>
>>>>
>>>> I've tried using implib too, but replacing dmd's own kernel32.lib seems
>>>> to create problems.
>>>
>>> What sort of problems? It's worked perfectly for me so far.
>>>
>>
>> PTLINK (R) for Win32 Release 8.00.12
>> opyright (C) Digital Mars 1989-2010 All rights reserved.
>> ttp://www.digitalmars.com/ctg/optlink.html
>> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
>> Error 42: Symbol Undefined _LocalFree@4
>> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
>> Error 42: Symbol Undefined _WideCharToMultiByte@32
>>
>> etc..
>>
>> I tried to replace kernel32.lib like this:
>> c:\dmd\windows\lib>implib /system kernel32.lib
>> \Windows\system32\kernel32.dll
>>
>> As this didn't work, I recompiled druntime and phobos with the new
>> kernel32.lib, but I get the same errors.
>
> Both those symbols are definitely present in the kernel32.lib that comes
> with DMD 2.053. Just grep for them and you'll see. There is something
> going on with either your DMD install or the command line passed to the
> linker.


These errors comes after replacing kernel32.lib in dmd. Not sure if that was clear from my post.

How is kernel32.lib supplied with dmd created?

This is a simple test showing a missing symbol:
pragma(lib, "kernel32.lib");
extern(Windows) {
    uint LocaleNameToLCID(const(wchar)*, int);
}

void main() {
    auto us = LocaleNameToLCID("en-US", 0);
}
July 31, 2011
On 30.07.2011 16:30, torhu wrote:
> On 30.07.2011 11:43, simendsjo wrote:
>> On 29.07.2011 22:06, Simon wrote:
>>> On 29/07/2011 19:27, simendsjo wrote:
>>>> On 29.07.2011 19:13, Simon wrote:
>>>>> On 29/07/2011 11:14, simendsjo wrote:
>>>>>> Not sure how I can search for symbols in the library, but it seems
>>>>>> the
>>>>>> library is missing functions.
>>>>>> I've tried using coffimplib on kernel32.lib from the Windows SDK,
>>>>>> but it
>>>>>> neither produces a new library or give me an error.
>>>>>>
>>>>>> What Windows version is the library based on?
>>>>>> How can I check what symbols exists?
>>>>>> Is there a way to convert WinSDK's library to omf?
>>>>>
>>>>> Shows how to make your own import lib for windows system dll:
>>>>>
>>>>> http://www.sstk.co.uk/d.php
>>>>>
>>>>> Been ages since I did that though so let me know if you have problems.
>>>>>
>>>>
>>>> I've tried using implib too, but replacing dmd's own kernel32.lib seems
>>>> to create problems.
>>>
>>> What sort of problems? It's worked perfectly for me so far.
>>>
>>
>> PTLINK (R) for Win32 Release 8.00.12
>> opyright (C) Digital Mars 1989-2010 All rights reserved.
>> ttp://www.digitalmars.com/ctg/optlink.html
>> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
>> Error 42: Symbol Undefined _LocalFree@4
>> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
>> Error 42: Symbol Undefined _WideCharToMultiByte@32
>>
>> etc..
>>
>> I tried to replace kernel32.lib like this:
>> c:\dmd\windows\lib>implib /system kernel32.lib
>> \Windows\system32\kernel32.dll
>>
>> As this didn't work, I recompiled druntime and phobos with the new
>> kernel32.lib, but I get the same errors.
>
> Both those symbols are definitely present in the kernel32.lib that comes
> with DMD 2.053. Just grep for them and you'll see. There is something
> going on with either your DMD install or the command line passed to the
> linker.

The implib created file is different from the one in the distribution, but I have no idea what this means:

** ORIGINAL **
==============

c:\dmd\windows\lib>find "LocalFree" kernel32.lib

---------- KERNEL32.LIB
        LocalFree
♀_LocalFree@4♀KERNEL32.dll      LocalFree
♀_LocalFree@4}♀


** IMPLIB **
============

c:\dmd\windows\lib>implib /system kernel32.lib \Windows\system32\kernel32.dll

c:\dmd\windows\lib>find "LocalFree" kernel32.lib

---------- KERNEL32.LIB
        LocalFree
_LocalFree♀kernel32.dll LocalFree
_MoveFileExA!╔¶↓_QueryPerformanceCounter!c▬¶_ReadConsoleOutputA!╙▬
_LocalFreeZ¶
July 31, 2011
On 30.07.2011 16:30, torhu wrote:
> On 30.07.2011 11:43, simendsjo wrote:
>> On 29.07.2011 22:06, Simon wrote:
>>> On 29/07/2011 19:27, simendsjo wrote:
>>>> On 29.07.2011 19:13, Simon wrote:
>>>>> On 29/07/2011 11:14, simendsjo wrote:
>>>>>> Not sure how I can search for symbols in the library, but it seems
>>>>>> the
>>>>>> library is missing functions.
>>>>>> I've tried using coffimplib on kernel32.lib from the Windows SDK,
>>>>>> but it
>>>>>> neither produces a new library or give me an error.
>>>>>>
>>>>>> What Windows version is the library based on?
>>>>>> How can I check what symbols exists?
>>>>>> Is there a way to convert WinSDK's library to omf?
>>>>>
>>>>> Shows how to make your own import lib for windows system dll:
>>>>>
>>>>> http://www.sstk.co.uk/d.php
>>>>>
>>>>> Been ages since I did that though so let me know if you have problems.
>>>>>
>>>>
>>>> I've tried using implib too, but replacing dmd's own kernel32.lib seems
>>>> to create problems.
>>>
>>> What sort of problems? It's worked perfectly for me so far.
>>>
>>
>> PTLINK (R) for Win32 Release 8.00.12
>> opyright (C) Digital Mars 1989-2010 All rights reserved.
>> ttp://www.digitalmars.com/ctg/optlink.html
>> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
>> Error 42: Symbol Undefined _LocalFree@4
>> :\dmd\windows\bin\..\lib\phobos.lib(dmain2)
>> Error 42: Symbol Undefined _WideCharToMultiByte@32
>>
>> etc..
>>
>> I tried to replace kernel32.lib like this:
>> c:\dmd\windows\lib>implib /system kernel32.lib
>> \Windows\system32\kernel32.dll
>>
>> As this didn't work, I recompiled druntime and phobos with the new
>> kernel32.lib, but I get the same errors.
>
> Both those symbols are definitely present in the kernel32.lib that comes
> with DMD 2.053. Just grep for them and you'll see. There is something
> going on with either your DMD install or the command line passed to the
> linker.

Hmmm.. Got coffimplib working. No idea what I did to break it before.
http://stackoverflow.com/questions/6889351/replacing-dmds-kernel32-lib-to-include-missing-functions/6889398#6889398