Linking with/Debugging static C/C++ libraries

Jeff Slutter MrMustard at gmail.com
Sun May 29 19:09:22 PDT 2011


I'm just starting out in my journey of R&D/evaluation of using D, as a
possible future development platform, for my team at work. I like a lot
of what I see!

Currently we do all our development in Visual Studio, using C/C++ (and
C# for some tools), and it is definitely the 'comfort zone' for the
team. My goal is to reduce the learning curves, and new tools they'll
have to pick up. The Visual D project is of great interest to me.

One of the things that's important to us is being able to link against
some existing C/C++ static libraries (built with VS 2008, so PE COFF
format). In some light testing I was able to link a D2 project with a
C/C++ Static library project in VS/VisualD with DMD. I had to use the
objconv.exe tool, as the Digital Mars tool coff2omf.exe seems to be too
old to work with the newer MS generated libraries. Unfortunately, it
looks like objconv will always strip out debugging information, and
while I had successful link and execution, I could only debug the D
code, there was no debugging information for the C/C++ code.

I suppose if the C/C++ code was in a DLL and D referenced the import
lib, things would work much better, but there are some cases where our
applications really need to come as a single executable and not have
dependent DLLs along for the ride.

Am I missing some sort of process or tool to make this all happen how I
want? I want to be able to link C/C++ static libraries, generated with
Visual Studio, with DMD, and maintain debugging information. Yes, I
know, that is not a simple request. :)

For what it's worth, using GDC and GCC/MingW (TDM), I was able to build
and debug a D/C/C++ mixed executable. I had to use GDB (though WinGDB
works just dandy), but the downside is I'm not using Visual D (unless
Visual D supports GDC??), nor DMD. DMD seems that it would be more
supported and stable right now than GDC, which seems to play catch up. I
worry that, as a user of GDC, hitting a compiler bug, would take longer
to get an official fix for, than it would for DMD.

Thanks everyone...
Jeff




More information about the Digitalmars-d-learn mailing list