Re: Linking with objects created from c code



robert.c.macleod@xxxxxxxxx wrote:

Hi,

I'm trying link in an object file generated from c code into a
delphi application using Delphi 2007 with the following directive:

{$L c_unit.obj}

I get the following error: E2045 Bad object file format: 'C:\opi\c
\c_unit.obj'

c_unit.obj generated by command: cl -c c_unit.c
cl is from microsoft visual c/c++ (version 6).

Delphi only links to object files in OMF format, not to ones in the
COFF format VC++ and GNU C++ produce. So use a Borland compiler (see
article linked to below) to compile your C file and it should work.

Much more about this, and some answers can be found here:

"Using C object files in Delphi"
http://rvelthuis.de/articles/articles-cobjs.html

--
Rudy Velthuis http://rvelthuis.de

"Democracy is where you can say what you think even if you don't
think."
.



Relevant Pages

  • Re: Linking with objects created from c code
    ... delphi application using Delphi 2007 with the following directive: ... I get the following error: E2045 Bad object file format: 'C:\opi\c ... Most probably Delphi doesn't support any but the format of its own C++ personality. ...
    (comp.lang.pascal.delphi.misc)
  • Linking with objects created from c code
    ... delphi application using Delphi 2007 with the following directive: ... I get the following error: E2045 Bad object file format: 'C:\opi\c ... I get a similar error when I try the gcc command (out of the gnat ...
    (comp.lang.pascal.delphi.misc)
  • Delphi and C++ object file
    ... Is it possible to debug C++ code that was compiled with bcc32 from within ... Delphi? ... The C++ object file is linked using the directive and works, ... what compiler switches do I need to use ...
    (borland.public.delphi.non-technical)
  • Re: How to compile g95 and get 64-bit executable (Question reformulated)
    ... > and this compiler generates also some 32-bit executable (after I ... a 32 bit ELF executable just specifies the object file ... no matter what the platform or the object file format. ...
    (comp.lang.fortran)
  • Source code of .obj capable assembler?
    ... like to create an assembler that can create LINK.exe compatible WIN32 ... Microsoft's newer win32 object file format." ... which makes me fear that the "newer win32 object file format" is not ...
    (comp.lang.asm.x86)