Export values (enum, int, char[]...) for DLL

Nrgyzer nrgyzer at gmail.com
Thu May 6 07:06:40 PDT 2010


torhu Wrote:

> On 04.05.2010 21:46, Nrgyzer wrote:
> > Hello everybody,
> >
> > I'm trying to create a (very) simple DLL by using D. Now I want export values - is there any way do this...
> 
> Off the top of my head, I think it goes like this:
> 
> To export from a DLL:
> export int i = 7;
> 
> To export from a DLL, with C name mangling:
> export extern (C) int i = 7;
> 
> 
> To import from a DLL:
> export extern int i;
> 
> To import from a DLL with a C interface:
> export extern extern (C) int i;
> 
> 
> I'm not sure if I recall the export part correctly, it's been a while 
> since I actuall tried this.

Thanks, but doesn't work :(

My files contain:

mydll.d:

module mydll;
export extern int i;

mydll2.d:

module mydll;
export int i = 7;

test.d:

import mydll;
import std.stdio;

void main() {
	writefln(i);
}

I can compile the dll, but when I compile test.d, I get the following error: "Error 42: Symbol Undefined _D5mydll1ii"


More information about the Digitalmars-d-learn mailing list