Issue with linking to dll

Stephen Jones siwenjo at gmail.com
Tue May 28 22:47:49 PDT 2013


I am trying to get my head around linking to dlls, and have been 
playing around with the mydll sample distributed with dmd2.062. 
If I create mydll.lib from implib with the driver (implib /noi /s 
mydll.lib mydll.dll) I get a lib file that I can link in with an 
interface file (dmd test.d mydll.di mydll.lib) to get a working 
exe.

But if I gendef a .def file off the dll (gendef mydll.dll), and 
reconstruct the lib file from the def file (implib /noi /s 
mydll.def) I can no longer use the d interface file to construct 
a valid exe (dmd test.d mydll.di mydll.lib). The error returned 
is:

...\lib\phobos.lib(dmain2)
Error 42: Symbol undefined _D5mydll8dllprintFZv

Which is odd because the def file is:

;
; Definition file of MYDLL.DLL
; Automatic generated by gendef
; written by Kai Tietz 2008
;
LIBRARY "MYDLL.DLL"
EXPORTS
D5mydll8dllprintFZv

Which does not underscore the symbol. I have tested implib with 
/system switch rather than /s, and without the /s switch at all, 
in all cases I get the same error.

If I open both mydll.lib files (from dll and from def) I find 
that the from dll lib file does contain the symbol with an 
underscore, whereas the lib from the def file does not.

Have I missed something to do with gendef?


More information about the Digitalmars-d-learn mailing list