digitalmars.D - Possible workaround for static linking of C and D obj files on Win32
Andrej Mitrovic <none none.none> writes:
Currently we have this issue where we can't link D combiled object files with C applications on Win32 (assuming the D code exports some names with extern(C)). The problem is optlink outputs OMF type object files, and pretty much all modern Win32 C compilers (VC/MinGW) expect COFF object file types. There's agner's objconv tool that can dissasemble optlink's OMF format, but it won't convert optlink's OMF to COFF since it keeps running into errors. However, there might be a workaround. *Please not that this is purely experimental*: First, download the Delphi Driver Development Kit (DDDK) from here: https://sites.google.com/site/delphibasics/home/delphibasicsprojects/delphidriverdevelopmentkit In the bin folder there's a tool called 'omf2d'. This is a tool that converts Borland's OMF to Intel OMF format, but it seems to be able to convert Optlink's OMF format to an OMF format that Objconv can use. My guess is that omf2d simply discards sections it doesn't understand and therefore Objconv uses the resulting object file without errors. I do not know how safe this is, so take it with a large grain of salt. Second, download objconv.exe from: http://www.agner.org/optimize/. Third, make sure you have MinGW installed since it comes with gcc.exe which we'll use, or you can modify the batch file I'm providing and use MSVC instead (I haven't tested this with MSVC yet). Make sure both omf2d and objconv are in PATH. Then, download the zip file with the sample project, extract and run the batch file that does all the work: http://dl.dropbox.com/u/9218759/staticObjLink.zip I've tried using this with .lib files, but Objconv couldn't convert the .lib file even after passing it through omf2d, it still keeps getting errors. So for now this only seems to work with .obj files (compiled with DMD -c). And I don't know to what extent this will work since this is the only example I've tried using this technique with for now.
Jan 17 2011
Xiemargl <Xiemargl gmail.com> writes:
Did you try the Open Watcom Linker? It support OMF, COFF, AR, ELF, but no x64.
Jan 31 2011