www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linking DMD Object Files with other compilers object files.

reply "Bruno Medeiros" <daiphoenixNOSPAM lycos.com> writes:
Hello!
 I want to link D object files with C objects files, but I'm running with 
some compatibility problems because I want to use a different compiler for C 
code (Mingw or VC++).
For what I've learned (correct me if I'm wrong) DMD produces OMF object 
files and Mingw and VC++ produce COFF object files (I don't even know if 
these last two COFF files are compatible).
I would appreciate some help on this issue. Can DMD only produce files in 
the OMF format? (an outdated and bad format for what I've read) Or is there 
a tool to convert betwen these two formats? (I did a quick search on google 
but didn't find anything) Are there any issues in the convertion?

Bruno Medeiros 
Apr 29 2005
next sibling parent bobef <bobef_member pathlink.com> writes:
Sounds like fairytail to me... It would be too nice if all things were comatible
;]

In article <d4u9hk$1npu$1 digitaldaemon.com>, Bruno Medeiros says...
Hello!
 I want to link D object files with C objects files, but I'm running with 
some compatibility problems because I want to use a different compiler for C 
code (Mingw or VC++).
For what I've learned (correct me if I'm wrong) DMD produces OMF object 
files and Mingw and VC++ produce COFF object files (I don't even know if 
these last two COFF files are compatible).
I would appreciate some help on this issue. Can DMD only produce files in 
the OMF format? (an outdated and bad format for what I've read) Or is there 
a tool to convert betwen these two formats? (I did a quick search on google 
but didn't find anything) Are there any issues in the convertion?

Bruno Medeiros 
Apr 29 2005
prev sibling next sibling parent Jan Jezabek <jezabek poczta.onet.pl> writes:
Bruno Medeiros wrote:
 Hello!
  I want to link D object files with C objects files, but I'm running with 
 some compatibility problems because I want to use a different compiler for C 
 code (Mingw or VC++).
 For what I've learned (correct me if I'm wrong) DMD produces OMF object 
 files and Mingw and VC++ produce COFF object files (I don't even know if 
 these last two COFF files are compatible).
 I would appreciate some help on this issue. Can DMD only produce files in 
 the OMF format? (an outdated and bad format for what I've read) Or is there 
 a tool to convert betwen these two formats? (I did a quick search on google 
 but didn't find anything) Are there any issues in the convertion?
 
 Bruno Medeiros 
 
 
You may want to try this: use ndisasm to disassemble the OMF and then nasm to assemble it to COFF. You can find both at nasm.sourceforge.net . I don't know if this will work, and I believe that even if it does you'll run across several other problems like name mangling etc. Regarding Mingw/VC++ COFF - they are somewhat compatible, I was able to link object files from both compilers; of course I was sticking to C to avoid problems with new/delete and name mangling. Regards, JJ
Apr 29 2005
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"Bruno Medeiros" <daiphoenixNOSPAM lycos.com> wrote in message
news:d4u9hk$1npu$1 digitaldaemon.com...
 Hello!
  I want to link D object files with C objects files, but I'm running with
 some compatibility problems because I want to use a different compiler for
C
 code (Mingw or VC++).
 For what I've learned (correct me if I'm wrong) DMD produces OMF object
 files and Mingw and VC++ produce COFF object files (I don't even know if
 these last two COFF files are compatible).
 I would appreciate some help on this issue. Can DMD only produce files in
 the OMF format? (an outdated and bad format for what I've read) Or is
there
 a tool to convert betwen these two formats? (I did a quick search on
google
 but didn't find anything) Are there any issues in the convertion?
This issue comes up often. I updated the FAQ for it. www.digitalmars.com/d/faq.html#omf
Apr 30 2005
parent Bruno Medeiros <daiphoenixNOSPAM gmail.com> writes:
Walter wrote:
 "Bruno Medeiros" <daiphoenixNOSPAM lycos.com> wrote in message
 news:d4u9hk$1npu$1 digitaldaemon.com...
 
Hello!
 I want to link D object files with C objects files, but I'm running with
some compatibility problems because I want to use a different compiler for
C
code (Mingw or VC++).
For what I've learned (correct me if I'm wrong) DMD produces OMF object
files and Mingw and VC++ produce COFF object files (I don't even know if
these last two COFF files are compatible).
I would appreciate some help on this issue. Can DMD only produce files in
the OMF format? (an outdated and bad format for what I've read) Or is
there
a tool to convert betwen these two formats? (I did a quick search on
google
but didn't find anything) Are there any issues in the convertion?
This issue comes up often. I updated the FAQ for it. www.digitalmars.com/d/faq.html#omf
Yup, I've read it, and made some simple tests and it worked. A few more questions though:
 "conforming to the usual C ABI interface"
Well, a restriction like that was to be expected. But that also means I can use C++ code that I can put inside a extern "C" {} , right? It says on the FAQ you can convert libraries "that come in the form of a DLL", but on the coff2omf page it says you can also convert .obj files. I tried a simple test with MingW and a VStudio 2005 generated .obj's. The MingW .obj worked, the VStudio .obj didn't (link errors with the Debug .obj, and runtime access violations with the Release .obj). What more should I know about converting .obj files (besides that they should have the C ABI) ? Or should I just stick with import libraries? Also, is the DM coff2omf tool freely available? On the DM website it says it's part of the (paid) Extended Utility package, and I had to use google to find a download link, which did happen to be on the DM site though (ftp://ftp.digitalmars.com/Digital_Mars_C++/Patch/COFF2OMF.zip), but for which I don't even know if its the latest version. Bruno Medeiros
May 17 2005