Thread overview | |||||
---|---|---|---|---|---|
|
July 18, 2004 Compiling D to a DLL | ||||
---|---|---|---|---|
| ||||
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 |
July 18, 2004 Re: Compiling D to a DLL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Garett Bass | 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, >Garett > > Yes, 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 |
July 18, 2004 Re: Compiling D to a DLL | ||||
---|---|---|---|---|
| ||||
Posted in reply to Deja Augustine | Deja Augustine wrote: > 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, >>Garett >> >> > > > > Yes, 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. 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. > > > 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/ |
Copyright © 1999-2021 by the D Language Foundation