DMD, LDC, shared objects, rpath

bachmeier via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Thu Jun 22 12:19:51 PDT 2017


On Thursday, 22 June 2017 at 18:18:29 UTC, kinke wrote:

> Nope, that should definitely work (exporting/importing 
> functions via `export` visibility). Just verified with LDC 
> 1.3-beta2 on Win64:
>
> D:
> import core.stdc.stdio;
> export extern(C) void exportedFoo() { 
> printf("exportedFoo()\n"); }
>
> C:
> extern "C" void exportedFoo();
> int main(int argc, char** argv)
> {
>     exportedFoo();
>     return 0;
> }
>
> ldc2 -shared dmodule.d => generates dmodule.{dll,lib,exp}
> cl cppmodule.cpp dmodule.lib => generates cppmodule.exe relying 
> on dmodule.dll
>
> Produces the expected output.
>
> As David mentioned, being able to use a single shared runtime 
> (druntime/Phobos DLLs) for multiple D binary modules and 
> getting full C++ DLL interop to work is a whole different 
> beast, requiring among other things a language change 
> (`export`: from visibility to stand-alone attribute).

Thanks! Turns out it was user error: I didn't know about the need 
for export. I added it and now everything works. What a pleasant 
surprise.


More information about the digitalmars-d-ldc mailing list