Last update March 7, 2012

Doc Comments /
DLLs



Difference (last change) (no other diffs, normal page display)

Changed: 70,181c70
*Best Practicies guide for Dlls in D: BestPractices/DLL
jam tangan
jam tangan murah
jam tangan kw
hostgator coupon
kata mutiara
Jasa SEO
EZido
RDAnet
pioneer deh-1300mp
asus a53e-xa2
asus tf101-b1
asus tf101-a1
asus n53sv-eh72
asus republic of gamers g74sx
asus acer a5250
acer chromebook ac700
asus asus 53u
lg infinia 55lw5600
Sonicview 360 premier
asus 7 cu ft freezer
asus 30 single wall oven
brother cs6000i sewing machine
brother 1034d serger
brother sewing machines
Yokohama Geolandar H/T-S
crib tent tots in mind
kidco peapod plus
foscam fi8910w
samsung pl120 review
gopro helmet cam
Canon SX130IS
powershot s100
ContourHD 1080p
canon vixia hf r21
digital picture frame
canon ef 50mm f1.4
canon ef 70-300mm review
wide angle lenses
moving comfort sports bra
moving comfort bra
womens argyle sweater
bebe dresses
ViewSonic VX2250WM
Le Pan TC 970
Apple MacBook Air MC965LL
Sennheiser CX 880
plantronics cs540
ultrasonic jewelry cleaner
Sennheiser RS120
bose quietcomfort 15 acoustic noise cancelling headphones
logitech harmony one remote
logitech harmony 900
sony mhc-ec69i
sony mhcec909ip
bose wave music system
sony htss380
logitech squeezebox touch
sony dvp-fx970
onkyo tx-nr509
onkyo tx - nr609
onkyo ht-s3400
energy 5.1 take classic home theater system
polk audio psw505
onkyo ht-s5400
onkyo tx-nr709
belkin pf60
onkyo ht-rc360
denon avr-1912
Yamaha YHT-S400BL
fujitsu scansnap s1500
brother hl-2270dw
epson workforce 545
hp laserjet p2055dn
bushnell 8mp trophy cam
toshiba 32c110u
panasonic viera tc-p60s30
VIZIO E220VA
hauppauge wintv dcr-2650
Acer AM3970-U5022
Acer AspireRevo AR3700-U3002
Dell Inspiron i570
Dell GX620
Gateway FX6860-UR20P
Western Digital My Passport Essential SE 1 TB USB 3.0
Fujitsu ScanSnap S1300
Epson Perfection V300
Fujitsu SCANSNAP S1100
NeatDesk Desktop Scanner and Digital Filing System
Epson WorkForce Pro GT-S50
Kodak P811BK
Epson Perfection V330
Viewsonic VX2453MH
Asus VE228H
ViewSonic VA2431WM
Samsung B2230
HP 2711x
ASUS ML228H
Epson PowerLite Home Cinema 8350
Optoma PK301
Epson EX7210
Epson EX5210
ViewSonic PJD5133
Acer X1161P
FAVI RioHD-LED-2
Epson EX3210
ViewSonic PJD6531w
Trinity 360 Breville 800JEXL
Skil 3320-02
Delta 46-460
Grizzly G0555
Delta 18-900L
*Best Practicies guide for Dlls in D: BestPractices/DLL

Writing Win32 DLLs in D    

Table of contents of this page
Writing Win32 DLLs in D   
Message   
Possible Anachronisms   
Calling a D DLL from MinGW or Microsoft Visual C/C++   
Links   

Message    

Add your comments page here.

Possible Anachronisms    

I think there are some anachronisms in the DLL examples. For instance function pointers are called using (*fp)(args) syntax, but these days you can just call a function pointer like a normal function, fp(args).

Calling a D DLL from MinGW or Microsoft Visual C/C++    

Here's one way to make a DLL that you can call your D code from C/C++ (and probably any language that can grok the C ABI). First follow the procedure in the spec ( D 1.x, D 2.x) to create the DLL. Note that I found that this minimal .def file seems to suffice:

   LIBRARY mydll.dll
   EXETYPE NT

Namely it is not necessary to list your exports. They will still be in there if you have marked them as "extern(C) export" in the source files.

For convenience here is an example dmd DLL compile/link command:

   dmd -ofmydll.dll mydll.d minimal.def 

You can also use Bud to create the dll. The only trick is that (with Bud v3.04) you need to add user32.lib and kernel32.lib.

   bud mydll.d user32.lib kernel32.lib 

Next you need to make a Microsoft COFF format import lib from the dll. Microsoft's lib.exe tool can do that, but it does need the list of exported functions in a .def file to work. Fortunately there's a free tool called 'pexports' that you can download that will do the trick:

     http://www.emmestech.com/software/cygwin/pexports-0.43/download_pexports.html 

For Microsoft VC++, To create the import lib, use these commands

    pexports -o mydll.dll > mydll.def
    lib /machine:x86 /def:mydll.def /out:mydll_vc.lib

Make sure Microsoft's VC bin directory is early on your path so that you get Microsoft's lib and not DMD's. Double check by typing 'lib' at the command prompt. If you don't see "Microsoft(R) Library Manager Version ..." then fix your path until you do.

For MinGW you can do:

    pexports -o mydll.dll > mydll.def
    c:\MinGW\bin\dlltool.exe --dllname mydll.dll --def mydll.def --output-lib mydll_vc.lib

Now you can use your favorite tools to link your C/C++ code to mydll_vc.lib.

This was tested with Visual Studio.NET 7.1 and 8.0, and with MinGW dlltool version 2.15.91.

NOTE: At the time of this writing (19-Feb-2007) Rebuild seem to have issues with building proper DLLs. Rebuild 0.8 just says "No 'link' setting configured."

-- BillBaxter

Links    


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: March 7, 2012 20:23 (diff))