Export values (enum, int, char[]...) for DLL
Nrgyzer
nrgyzer at gmail.com
Thu May 13 09:23:14 PDT 2010
Nrgyzer Wrote:
> torhu Wrote:
>
> > On 06.05.2010 16:06, Nrgyzer wrote:
> > > 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"
> >
> > It seems that export doesn't work for data, only functions. If you
> > build with -map, you'll see that i is not exported. I got it working by
> > using this .def file:
> >
> > LIBRARY "mydll.dll"
> > EXETYPE NT
> > EXPORTS
> > D5mydll1ii
> >
> >
> > Then create the import lib with:
> > implib /s mydll.lib mydll.dll
> >
> > /s adds the underscores.
> >
> >
> > If you use extern (C) the symbols will be a lot simpler to read and
> > write, though. Look at the .map file to see what the actual symbols are.
>
> Thanks - works :)
Hello,
dmd now exports all values successfully. But when I try to export a class, I get the following errors:
"Error 42: Symbol Undefined _D5mydll1t7__ClassZ
Error 42: Symbol Undefined _D5mydll1t5_ctorMFZC11mydll1t"
Source of mydll.d is:
export class t {
export this();
}
Source of mydll2.d is:
import std.stdio: writefln;
export class t {
export this() {
writefln("hello world!");
}
}
Source of test.d:
pragma(lib, "mydll.lib");
import mydll;
void main() {
t myTest = new t();
}
When I export D5mydll1t7__ClassZ in my def-File, I can compile it but when I try to create a new instance of t, I get an access violation :(.
More information about the Digitalmars-d-learn
mailing list