digitalmars.D.learn - Issue with linking to dll
- Stephen Jones (29/29) May 28 2013 I am trying to get my head around linking to dlls, and have been
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?
May 28 2013