digitalmars.D - Compiling D to a DLL
- Garett Bass (5/5) Jul 17 2004 I've been reading up on the DMD compiler, and I can't find an option to
- Deja Augustine (24/29) Jul 18 2004 Yes, it is possible, and doesn't even require a command-line switch to d...
- J C Calvarese (9/59) Jul 18 2004 An example of creating a DLL in Windows is here:
I've been reading up on the DMD compiler, and I can't find an option to compile to a dynamically linked library. Is this currently possible? Thanks in advance. Regards, Garett
Jul 17 2004
In article <cdd5ak$223b$1 digitaldaemon.com>, Garett Bass says...I've been reading up on the DMD compiler, and I can't find an option to compile to a dynamically linked library. Is this currently possible? Thanks in advance. Regards, GarettYes, it is possible, and doesn't even require a command-line switch to do. All you need to do is create a Library Definition File (*.def). Here's an example: ================= Begin test.def ================= // Do not include this line LIBRARY TEST DESCRIPTION 'An Example DLL' EXETYPE NT CODE PRELOAD DISCARDABLE DATA PRELOAD SINGLE EXPORTS testfunction 2 anotherfunction 3 ================= End test.def ================= // Do not include this line Your methods need to be marked as extern as well as listed in the definition file. If you want to see a working example, check out http://www.scratch-ware.net/d/ to see the Python/D DLL example at the bottom. You can also look at the D for Win32 link: http://www.digitalmars.com/d/windows.html and scroll down to DLL (Dynamic Link Libraries) for a rundown including this link: http://www.digitalmars.com/ctg/ctgDefFiles.html which describes in detail how to construct a .def file Hope this helps -Deja
Jul 18 2004
Deja Augustine wrote:In article <cdd5ak$223b$1 digitaldaemon.com>, Garett Bass says...An example of creating a DLL in Windows is here: http://spottedtiger.tripod.com/D_Language/D_Hub_Adv_Tutor_XP.html It shows how to create a DLL. Then copy the DLL into C:\dmd\MKoD_ex\WinDLL.dll Then it shows how to create a file that uses the DLL. Great stuff.I've been reading up on the DMD compiler, and I can't find an option to compile to a dynamically linked library. Is this currently possible? Thanks in advance. Regards, GarettYes, it is possible, and doesn't even require a command-line switch to do. All you need to do is create a Library Definition File (*.def). Here's an example: ================= Begin test.def ================= // Do not include this line LIBRARY TEST DESCRIPTION 'An Example DLL' EXETYPE NT CODE PRELOAD DISCARDABLE DATA PRELOAD SINGLE EXPORTS testfunction 2 anotherfunction 3 ================= End test.def ================= // Do not include this line Your methods need to be marked as extern as well as listed in the definition file. If you want to see a working example, check out http://www.scratch-ware.net/d/ to see the Python/D DLL example at the bottom.You can also look at the D for Win32 link: http://www.digitalmars.com/d/windows.html and scroll down to DLL (Dynamic Link Libraries) for a rundown including this link: http://www.digitalmars.com/ctg/ctgDefFiles.html which describes in detail how to construct a .def file Hope this helps -Deja-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Jul 18 2004