digitalmars.D.learn - DLL under windows
DMD2.036. Under dmd/phobos release package,inside samples\d\mydll folder,there is a sample to write dll and import lib fille from.It compiled and runs fine.But when I try to modify a bit,it produce strange error problem.Kindly refer to the sample for source. In mydll2.d which contains the exported function implentation: module mydll; import core.stdc.stdio; export void dllprint() { printf("hello dll world\n"); } I re-wrote dllprint with below: export ulong dllprint(uint i) { ulong sum; if(i==0) sum=1; else { for(uint index=1;index<=i;index++) sum*=index; } return sum; } In mydll.d: Original: export void dllprint(); Modified: export ulong dllprint(uint i); In test.d: Original: import mydll; int main() { mydll.dllprint(); return 0; } Modified: ... printf("%d\n",mydll.dllprint(12)); ... Leave everything other unchanged. Error message when run test.exe: F:\DLang\DTwo\dmd\samples\d\mydll>dmd -ofmydll.dll mydll2.d dll.d mydll.def F:\DLang\DTwo\dmd\samples\d\mydll>implib/system mydll.lib mydll.dll Digital Mars Import Library Manager Version 7.6B1n Copyright (C) Digital Mars 2000. All Rights Reserved. Input is a Windows NT DLL file 'MYDLL.DLL'. Output is a Windows NT import library. Digital Mars Import Library Creator complete. F:\DLang\DTwo\dmd\samples\d\mydll>dmd test.d mydll.lib OPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html F:\DLang\DTwo\dmd\windows\bin\..\lib\phobos.lib(dmain2) Error 42: Symbol Undefined _D5mydll8dllprintFkZm --- errorlevel 1 F:\DLang\DTwo\dmd\samples\d\mydll> Was I missing something? Thanks for your help in advance. Regards, Sam
Nov 09 2009
Sam Hu wrote:DMD2.036. Under dmd/phobos release package,inside samples\d\mydll folder,there is a sample to write dll and import lib fille from.It compiled and runs fine.But when I try to modify a bit,it produce strange error problem.Kindly refer to the sample for source.Beware of bug 3342: at present you CANNOT use DLLs with D2 on Windows XP or earlier. That's not the problem here, but you need to know it. Just telling you before you waste lots of time.
Nov 10 2009
Don Wrote:Beware of bug 3342: at present you CANNOT use DLLs with D2 on Windows XP or earlier. That's not the problem here, but you need to know it. Just telling you before you waste lots of time.Thank you very much for letting me know!!
Nov 10 2009