Thread overview | |||||
---|---|---|---|---|---|
|
January 09, 2004 Export/Import classes to/from a dll? | ||||
---|---|---|---|---|
| ||||
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 Re: Export/Import classes to/from a dll? | ||||
---|---|---|---|---|
| ||||
Posted in reply to uwem | 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 Re: Export/Import classes to/from a dll? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 > > > > > > |
Copyright © 1999-2021 by the D Language Foundation