Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can 64 bit Delphi targets statically link to compiled C object files?

My 32 bit Delphi 2010 application links to a number of C object files using the $LINK compiler directive. Can I do this in Delphi XE2 when targetting 64 bit?

I am currently compiling using bcc32 version 5.5, but I don't mind which compiler I use if it turns out that the Embarcadero C compiler does not yet output 64 bit objects.

like image 570
David Heffernan Avatar asked Sep 01 '11 14:09

David Heffernan


2 Answers

Yes. You must compile the "C" objects files to COFF format. This usually means either the Intel and/or MSVC++ compilers. The same caveats apply to 64bit object file linking that apply to 32bit. You must ensure that all external references are properly resolved, either by providing another .obj which has that symbol, or from Delphi code. When building the "C" code, make sure you disable any stack checks or other run-time verification code generation. Many times such codegen relies on a specific version of the C/C++ RTL from the given tool.

Something else worth noting is that while Delphi 64bit can link to COFF object files (eventually it will also support ELF64), 32bit Delphi supports linking with C++Builder built OMF object files and, new to XE2, 32bit COFF object files which can be built with MSVC++. The same caveats apply.

like image 173
Allen Bauer Avatar answered Nov 18 '22 20:11

Allen Bauer


Yes, you can link to OBJ files in 64-bit XE2 projects, but the OBJ files have to be 64-bit code.

like image 25
Mason Wheeler Avatar answered Nov 18 '22 20:11

Mason Wheeler