I'm trying to figure how to use IMPLIB with D DLLs. The DLL example from the samples folder in DMD:
dll.d > http://pastebin.com/C9NJtqUV mydll.d > http://pastebin.com/8idbnge0 test.d > http://pastebin.com/6c953BSJ mydll.def > http://pastebin.com/4enbfbc7 First I'll show how to build without using IMPLIB (since I have the sources). I use a build command to create the header (interface) files & the import library, all in one go: $ dmd -L/IMPLIB -H -ofmydll.dll mydll.d dll.d mydll.def The dll is cooked, I have an import library (mydll.lib) and the interface files. Ok, now I link the library with my driver (test.d): dmd test.d mydll.lib $ test.exe > hello dll world Everything works ok. But, let's say I didn't have the d source files, and all I had was the .dll file, the .def file, and the interface files. I have to create the import lib with IMPLIB. I run the command: $ implib mydll2.lib mydll.def Then I try to link mydll2.lib with the driver: $ dmd test.d mydll2.lib > Error 42: Symbol Undefined _D5mydll8dllprintFZv --- errorlevel 1 The .lib file seems to be completely empty when I use IMPLIB this way. If instead of using the .def file I use the .lib file directly, like so: $ implib mydll3.lib mydll.dll then I get back a .lib file with some actual symbols (its 2KB compared to the first .lib file, which is 1KB), but I still can't link it: $ dmd test.d mydll3.lib Error 42: Symbol Undefined _D5mydll8dllprintFZv --- errorlevel 1 It seems to be that IMPLIB creates the lib files without underscores before the symbol names. To recap: The first mydll.lib which was created by DMD uses underscores before symbols, the second lib file created by IMPLIB and a .DEF file has no symbols in it, and the third lib file created by IMPLIB and mydll.dll exports symbols without underscores. So, am I missing an important step in building an import library with IMPLIB?