D - Export/Import classes to/from a dll?
- uwem (41/41) Jan 09 2004 Hello!
- Walter (7/48) May 19 2004 You need to create an import library from the dll, and then link that in...
- David Barrett (6/65) Jun 05 2004 Uwe -- Did you ever get this to work? Could you zip up your sample and ...
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
Jan 09 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 classfromthe generated dll in a other program? I generate a dll (set the class constructor and method to export, i have adeffile)-> dmd testdll.d testdll.def I generate a lib file with the implib tool and use this file with the dcompiler-> 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 19 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...classHello! A new year and a old question. How i can export a complete class to a dll and how i can import thisfromathe generated dll in a other program? I generate a dll (set the class constructor and method to export, i havedeffile)-> dmd testdll.d testdll.def I generate a lib file with the implib tool and use this file with the dcompiler-> 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
Jun 05 2004