Summary: Implicit linking with D DLLs doesn't work
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Andrej Mitrovic <> 2011-05-16 
16:02:19 PDT ---
Test case:

Use the build.bat file or issue these commands:
cd dll
dmd -H -of..\mydll.dll -L/IMPLIB mydll.d
dmd driver.d -I. dll\mydll.lib

The exported D function is found by the linker, and you can find the name in
the mydll.dll, mydll.lib, and driver.obj files, it has this name:

However DMD also generates a mydll.obj file which references this symbol:

This symbol isn't exported in the DLL and you won't find it in the import lib,
and hence the linker error.

Daniel Green made a comment from this thread

"Probably unrelated, but this same issue showed up in the GDC backend. 
Apparently, the compiler tried to be smart about exporting ModuleInfo 
only for those modules that needed it.  The fix was to always export it 

Note that you cannot just pass a .di header file directly to DMD because DMD
will statically compile the function found in the header file, and
the application won't need the DLL anymore.

You also cannot prototype the foo() function directly in driver.d, because this
function will be mangled together with its module name (mangled mydll.driver vs

The alternative is manually figuring out the mangling of the function name and
using explicit linking via GetProcAddress & friends.


One more thing: Apparently in v2.053 linking with core.dll_helper doesn't work
import core.dll_helper;
void main() {}

 Error 42: Symbol Undefined _D4core10dll_helper12__ModuleInfoZ
--- errorlevel 1

Is that a known issue? Linking with does work though.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to