DMD - Windows

Alex Rønne Petersen xtzgzorex at gmail.com
Fri Jan 6 15:11:12 PST 2012


On 06-01-2012 20:06, Nick Sabalausky wrote:
> "Manu"<turkeyman at gmail.com>  wrote in message
> news:mailman.118.1325874486.16222.digitalmars-d at puremagic.com...
>> Okay, so I was trying to link to a C lib, and I realised... DMD doesn't
>> support/produce VS compatible libs.
>> I should have realised this sooner, noting the cv debuginfo.
>>
>> So like... WTF?
>>
>> How am I supposed to use DMD in Windows in anything other than trivial,
>> self-contained programs?
>> VisualC is the de facto standard in Windows. All libs are COFF, and
>> (unless
>> I'm working with GCC) everything I want to link to is produced from VC.
>>
>> Let's also mention the debug info... Virtually every 3rd party tool
>> assumes
>> and/or works best with PDB debug info. Being required to run cv2pdb is
>> pretty lame.
>>
>> So... why no support for COFF libs, and PDB debug info?
>> Surely at least a compiler option would do the business if there is some
>> kinky attachment to CV and OMF :/
>>
>> I was hoping to start a project using D as a front end language
>> interacting
>> with my C/C++ engine lib... but I can't.
>> ... and now that I think if it... how do ANY programs built with DMD
>> actually work? .. How does it link to system32.lib, user32.lib, etc?
>>
>
> Yea, OMF is actually #1 PITA on Windows right now, unfortunately.
>
> The problem: On windows, DMD uses the Optlink linker. Optlink only supports
> OMF right now (OMF used to be commonly used by Borland, IIRC). Optlink was
> written entirely in asm so changing it is difficult. But Walter has been,
> piece-by-piece, porting it to C (and then he'll port it to D). (This is
> issue also happens to be the main thing blocking 64-bit on Windows.)
>
> There are a few solutions right now (in no particular order):
>
> - Recompile the libs using DMC (the Digital Mars C/C++ compiler). That will
> result in an OMF lib file that can be used with DMD.
>
> - Link with Unilink instead of DMD/Optlink. Unilink can link both OMF and
> COFF together just fine. I don't have a link offhand, and it's a little
> funky to learn how to use since the docs aren't very good, but I'm sure
> someone here will chime in (or you can search the archives, I know comeone
> posted a good introduction to it not too long ago).
>
> - Use the Digital Mars COFF2OMF tool to convert to lib to OMF.
> Unfortunately, the tool isn't free, but IIRC it's inexpensive.

There is the free objconv tool: http://www.agner.org/optimize/

>
> - Use LDC or GDC instead of DMD. I think those work with COFF.
>
> - If the library comes in a DLL version, you can download the free IMPLIB
> tool and use it to generate an OMF import library directly from the DLL
> (it'll still actually link to the DLL at runtime).
>
> - Search/Ask around: Someone may have already created an OMF version of the
> lib.
>
> The IMPLIB and COFF2OMF tools are here:
> http://www.digitalmars.com/download/freecompiler.html  IMPLIB is in the free
> "Basic Utilities" package, and COFF2OMF is in the "Extended Utilities
> Package"
>
> If you feel this is all still a big pain in the ass: Don't worry, everyone
> here agrees with you, and the situation will not remain like this forever.
>
>


-- 
- Alex


More information about the Digitalmars-d mailing list