Thread overview
Export/Import classes to/from a dll?
Jan 09, 2004
uwem
May 20, 2004
Walter
Jun 05, 2004
David Barrett
January 09, 2004
Hello!

A new year and a old question.
How i can export a complete class to a dll and how i can import this class from
the generated dll in a other program?
I generate a dll (set the class constructor and method to export, i have a def
file)-> dmd testdll.d testdll.def
I generate a lib file with the implib tool and use this file with the d compiler
-> dmd test.d testdll.lib
The error msg from OPTLINK:

hello.obj(hello)
Error 42: Symbol Undefined __Class_7testdll3Uwe
hello.obj(hello)
Error 42: Symbol Undefined _D7testdll3Uwe5_ctorFZC7testdll3Uwe

The class in the dll:
export class Uwe
{
public:
export this()
{
printf("Uwe::Uwe()\n");
}
export ~this()
{
printf("Uwe::~Uwe()\n");
}
export void doIt()
{
printf("Uwe::doIt()\n");
}
}

The test routine:

import testdll;

int main(char[][] args)
{
Uwe xx = new Uwe;

return 0;
}

I use windows.
Thanks in advance!

Bye
Uwe


May 20, 2004
You need to create an import library from the dll, and then link that into the main program so the linker can resolve the symbols.

"uwem" <uwem_member@pathlink.com> wrote in message news:btm84a$bpn$1@digitaldaemon.com...
> Hello!
>
> A new year and a old question.
> How i can export a complete class to a dll and how i can import this class
from
> the generated dll in a other program?
> I generate a dll (set the class constructor and method to export, i have a
def
> file)-> dmd testdll.d testdll.def
> I generate a lib file with the implib tool and use this file with the d
compiler
> -> dmd test.d testdll.lib
> The error msg from OPTLINK:
>
> hello.obj(hello)
> Error 42: Symbol Undefined __Class_7testdll3Uwe
> hello.obj(hello)
> Error 42: Symbol Undefined _D7testdll3Uwe5_ctorFZC7testdll3Uwe
>
> The class in the dll:
> export class Uwe
> {
> public:
> export this()
> {
> printf("Uwe::Uwe()\n");
> }
> export ~this()
> {
> printf("Uwe::~Uwe()\n");
> }
> export void doIt()
> {
> printf("Uwe::doIt()\n");
> }
> }
>
> The test routine:
>
> import testdll;
>
> int main(char[][] args)
> {
> Uwe xx = new Uwe;
>
> return 0;
> }
>
> I use windows.
> Thanks in advance!
>
> Bye
> Uwe
>
>


June 05, 2004
Uwe -- Did you ever get this to work?  Could you zip up your sample and post a link to it?

"Walter" <newshound@digitalmars.com> wrote in message news:c8hh8b$21e5$1@digitaldaemon.com...
> You need to create an import library from the dll, and then link that into the main program so the linker can resolve the symbols.
>
> "uwem" <uwem_member@pathlink.com> wrote in message news:btm84a$bpn$1@digitaldaemon.com...
> > Hello!
> >
> > A new year and a old question.
> > How i can export a complete class to a dll and how i can import this
class
> from
> > the generated dll in a other program?
> > I generate a dll (set the class constructor and method to export, i have
a
> def
> > file)-> dmd testdll.d testdll.def
> > I generate a lib file with the implib tool and use this file with the d
> compiler
> > -> dmd test.d testdll.lib
> > The error msg from OPTLINK:
> >
> > hello.obj(hello)
> > Error 42: Symbol Undefined __Class_7testdll3Uwe
> > hello.obj(hello)
> > Error 42: Symbol Undefined _D7testdll3Uwe5_ctorFZC7testdll3Uwe
> >
> > The class in the dll:
> > export class Uwe
> > {
> > public:
> > export this()
> > {
> > printf("Uwe::Uwe()\n");
> > }
> > export ~this()
> > {
> > printf("Uwe::~Uwe()\n");
> > }
> > export void doIt()
> > {
> > printf("Uwe::doIt()\n");
> > }
> > }
> >
> > The test routine:
> >
> > import testdll;
> >
> > int main(char[][] args)
> > {
> > Uwe xx = new Uwe;
> >
> > return 0;
> > }
> >
> > I use windows.
> > Thanks in advance!
> >
> > Bye
> > Uwe
> >
> >
>
>