Search code examples
windowsddmd

Replacing DMD's kernel32.lib to include missing functions


I'm using dmd 2.054 and optlink 8.00.12 on Windows 7.

The following program:

pragma(lib, "kernel32.lib");
extern(Windows) {
    uint LocaleNameToLCID(const(wchar)*, int);
}

void main() {
    auto us = LocaleNameToLCID("en-US", 0);
}

Gives an error when compiling:

 Error 42: Symbol Undefined _LocaleNameToLCID@8

But if I try to replace kernel32.lib, I get many errors:

implib /system kernel32.lib \Windows\system32\kernel32.dll

 Error 42: Symbol Undefined _LocaleNameToLCID@8
c:\dmd\windows\bin\..\lib\phobos.lib(dmain2)
 Error 42: Symbol Undefined _LocalFree@4
c:\dmd\windows\bin\..\lib\phobos.lib(dmain2)
(... snip ...)

Looking at the original lib and the implib created for LocalFree shows there are differences, but I'm not sure what that means (some special characters are missing from this output)

---------- IMPLIB
    LocalFree
_LocalFreekernel32.dll  LocalFree
_K32GetPerformanceInfo!_LocalFree!Z
_MoveFileExA!É_QueryPerformanceCounter!c_ReadConsoleOutputA!Ó
_LocalFreeZ


---------- DMD'S
    LocalFree
[email protected]    LocalFree
_LocalFree@4}

Any idea how I can use the new kernel32.lib in my programs to avoid missing symbols?


Solution

  • Nevermind..

    I had also tried using coffimplib earlier without success, but now it works. No idea what I've done earlier.

    So my solution has been to download the windows sdk and using coffimplib on the libraries I need.

    Sorry for the spam. If someone could tell me why implib doesn't work I'll accept that answer.