FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Static linking and debugging with C/C++

 
Post new topic   Reply to topic     Forum Index -> Visual D
View previous topic :: View next topic  
Author Message
midnite



Joined: 29 May 2011
Posts: 2

PostPosted: Sun May 29, 2011 1:50 pm    Post subject: Static linking and debugging with C/C++ Reply with quote

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. 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. I very much like the idea of Visual D, it would help make the shift to D a lot smoother.

One of the things that's important to us is being able to link against some existing C/C++ static libraries (built with VS, 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. 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 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 referenced with D, things would work much better, but there are some cases where our applications really need to come as a single .exe and not have dependent .dlls come along for the ride.

Am I missing some sort of process or tool to make this all happen how I want?

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), and the downside is I'm not using VisualD (unless VisualD supports GDC??), and the DMD compiler is a bit more up to date, and active, than GDC.

I guess this may be more DMD specific, but the readers of this forum are much more likely to know the answer because the Visual Studio nature of the question Smile

Thanks...
Back to top
View user's profile Send private message
sagitario



Joined: 03 Mar 2007
Posts: 292

PostPosted: Mon May 30, 2011 1:27 am    Post subject: Reply with quote

Hi,

even if the object file conversion would work perfectly, the D runtime library depends on the C runtime library of the dmc compiler, so it will be troublesome to link it with C code that relies on another C runtime library.

Here's a discussion of trying to remove the dependency on the Digital Mars C library (snn.lib) http://www.digitalmars.com/d/archives/digitalmars/D/Linking_COFF_and_OMF_130260.html , but I'm not sure that attempt was successful.

So, if you have to statically link D and C code, I would recommend trying to compile the C code with dmc. You can still setup a VS project (probably makefile) to take advantage of intellisense and other VS features. This would also allow handling of the debug information by the converter to pdb.
Back to top
View user's profile Send private message
midnite



Joined: 29 May 2011
Posts: 2

PostPosted: Mon May 30, 2011 8:03 am    Post subject: Reply with quote

Ah, now I see the posts of others trying to get the same results I'm looking for. I hope it gets resolved because that would surely help D adoption.

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Visual D All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group