digitalmars.D.learn - DLL Linking
- vermi (14/14) Jun 19 2007 Hi, i'm trying to build a dll with our favorite langage, but I have a li...
- vermi (5/24) Jun 19 2007 So strange, I have added a void main() {} And now it's seem to work !
- Extrawurst (2/32) Jun 19 2007
Hi, i'm trying to build a dll with our favorite langage, but I have a little problem. For now it's juste an "empty dll" (with just DllMain). I think the better is to show you the shell ouput : dmd.exe -O -w -IC:\dmd\src\phobos -IK:\Projects\D\V4D -c main.d -ofobj\Release\main.obj dmd.exe -ofbin\Release\V4D.dll obj\Release\main.obj phobos.lib link obj\Release\main,bin\Release\V4D.dll,,phobos.lib+user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved OPTLINK : Warning 23: No Stack obj\Release\main.obj(main) Error 42: Symbol Undefined __acrtused_dll OPTLINK : Warning 134: No Start Address I have looked on the site and have found a page (don't remember the url) telling to remove de -NL switch, add a .def file, ... But it's visibly not my problem :/. Can anyone help me ?
Jun 19 2007
So strange, I have added a void main() {} And now it's seem to work !
I have a DllMain and a main... Ôo
DllMain is executed when the dll is loaded.
An Explaination ?
vermi Wrote:
Hi, i'm trying to build a dll with our favorite langage, but I have a little
problem. For now it's juste an "empty dll" (with just DllMain).
I think the better is to show you the shell ouput :
dmd.exe -O -w -IC:\dmd\src\phobos -IK:\Projects\D\V4D -c main.d
-ofobj\Release\main.obj
dmd.exe -ofbin\Release\V4D.dll obj\Release\main.obj phobos.lib
link obj\Release\main,bin\Release\V4D.dll,,phobos.lib+user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
OPTLINK : Warning 23: No Stack
obj\Release\main.obj(main)
Error 42: Symbol Undefined __acrtused_dll
OPTLINK : Warning 134: No Start Address
I have looked on the site and have found a page (don't remember the url)
telling to remove de -NL switch, add a .def file, ... But it's visibly not my
problem :/.
Can anyone help me ?
Jun 19 2007
did you take a look at the DLL sample shiped with the dmd compiler ?
vermi schrieb:
So strange, I have added a void main() {} And now it's seem to work !
I have a DllMain and a main... Ôo
DllMain is executed when the dll is loaded.
An Explaination ?
vermi Wrote:
Hi, i'm trying to build a dll with our favorite langage, but I have a little
problem. For now it's juste an "empty dll" (with just DllMain).
I think the better is to show you the shell ouput :
dmd.exe -O -w -IC:\dmd\src\phobos -IK:\Projects\D\V4D -c main.d
-ofobj\Release\main.obj
dmd.exe -ofbin\Release\V4D.dll obj\Release\main.obj phobos.lib
link obj\Release\main,bin\Release\V4D.dll,,phobos.lib+user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
OPTLINK : Warning 23: No Stack
obj\Release\main.obj(main)
Error 42: Symbol Undefined __acrtused_dll
OPTLINK : Warning 134: No Start Address
I have looked on the site and have found a page (don't remember the url)
telling to remove de -NL switch, add a .def file, ... But it's visibly not my
problem :/.
Can anyone help me ?
Jun 19 2007
If you want the source code of my dll, it's so simple :
//// CODE BEGIN
import std.c.windows.windows;
HINSTANCE hInst;
extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID
pvReserved)
{
switch (ulReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
return false;
case DLL_THREAD_DETACH:
return false;
default:
}
hInst = hInstance;
return true;
}
// La fonction main() ne sert strictement a rien a part a faire fonctionner la
compilation
void main() { }
//// END OF CODE
The void main() { } allow me to link the dll, if I don't put it, the linker
tell me the message I wrote before.
This code is copy/past from samples on the digitalmars website.
Jun 19 2007
I have onen, here it is : LIBRARY V4D EXETYPE NT SUBSYSTEM WINDOWS CODE PRELOAD SHARED EXECUTE DISCARDABLE DATA PRELOAD SINGLE WRITE It appears on the command line : dmd.exe -ofbin\Release\V4D.dll V4D.def obj\Release\main.obj phobos.lib ( this is the executed command line ) dmd.exe call then : link obj\Release\main,bin\Release\V4D.dll,,phobos.lib+user32+kernel32,V4D.def/noi; Has you can see, the .def file appears in both command lines.
Jun 19 2007








vermi <moi_anti_spam_ vermi.fr>