Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OMF format to COFF format

is there any tool like Borland "coff2omf.exe"for converting Borland OMF LIB format to MS VC++ COFF LIB format ?

actually i want to create .obj file in delphi and use that in MSVC++ .

like image 694
Behrooz Avatar asked Dec 20 '22 04:12

Behrooz


2 Answers

Yes, there is such a tool.

See this tool.

This utility can be used for converting object files between COFF/PE, OMF, ELF and Mach-O formats for all 32-bit and 64-bit x86 platforms. Can modify symbol names in object files. Can build, modify and convert function libraries across platforms. Can dump object files and executable files. Also includes a very good disassembler supporting the SSE4, AVX, AVX2, FMA and XOP instruction sets. Source code included (GPL). Manual.

Note that this http://www.agner.org web site is the best resource I know about low-level optimization. All the linked information is worth reading, if you want to deal with performance.

But for using the Delphi-generated .obj with VC++, it won't be easily feasible, but for very small part of code. You will need the Delphi RTL used in your code. An external .dll is much better. Note also that some types (like strings or dynamic arrays) won't be easily modifiable in VC++.

like image 140
Arnaud Bouchez Avatar answered Dec 24 '22 01:12

Arnaud Bouchez


To the best of my knowledge there is no such tool. Using Agner Fog's object file converter, the tool that Arnaud refers to, I've never succeeded in converting a Delphi unit into a COFF .obj that can be linked to an MSVC program.

I do believe that it's not realistic to take Delphi source code, compile it, and then use the generated object in MSVC. The other direction is quite possible. You can compile C code to an object, and link that object to your Delphi executable. When you do this you need to resolve any dependencies that the compiled object has.

But to link a Delphi object into a C/C++ program is going to require whatever part of the Delphi RTL that you use. And that's going to be tricky unless you happen not to use any part of the Delphi RTL, which seems unlikely.

In your situation I think your options are:

  1. Port the code to C or C++.
  2. Compile the Delphi code into a dynamic library and link to that from your C++ program.
like image 28
David Heffernan Avatar answered Dec 24 '22 00:12

David Heffernan