打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
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.

asked Sep 1 '11 at 14:29
David Heffernan
243k16298526

3  
I have read somewhere that you can link COFF object files (created with MS VC++ as .obj files) in a 64 bit Delphi app. –  Warren P Sep 1 '11 at 14:33
1  
@Rudy It's already shipped. ELF's no good for Windows. –  David Heffernan Sep 1 '11 at 15:52

 
Of course you could use another compiler that can emit 64 bit COFF or whatever you need, perhaps one of the GNU or LLVM compilers? The BCC v. 5.5 compiler is the free one, I guess? It is already a bit old, and not very standard. –  Rudy Velthuis Sep 1 '11 at 15:52

 
@Rudy Yes the free one. Yes it is old, but it suffices perfectly well for me. The C code I'm compiling is even older, it mostly has been emitted from my favourite program, f2c -a. –  David Heffernan Sep 1 '11 at 16:02

 
Here is a link to a free trial –  LU RD Sep 1 '11 at 16:41
show 4 more comments

2 Answers

up vote 30 down vote accepted

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.

answered Sep 1 '11 at 18:12
Allen Bauer
11k2855


 
Thank you so much for replying Allen, this is exactly what I wanted to hear. I think at long last I'm about to come back to SA. One more question if you please, do you know if gcc/mingw produces objects that can be consumed by Delphi? –  David Heffernan Sep 1 '11 at 18:32
4  
It's also worth mentioning that the System.Win.Crtl.pas unit provides support for linking in many of the basic C runtime routines that are needed when linking in .obj files. This unit is part of the RTL package. See the comments / disclaimer / warning in the source file before you use it. :) –  Mark Edington Sep 15 '11 at 5:38

 
About OBJ formats (if e.g. you ask why the same file extension may have several formats), see agner.org/optimize site. It is updated frequently, contains a lot of interesting material, especially about 64 bit and cross-platform. There is even a converter between COFF/OMF formats, and some cross-platform decompiler. –  Arnaud Bouchez Oct 3 '11 at 10:21
add comment

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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
如何自己编写Makefile
3d2 format
Delphi中的Free和Nil
Ajax POST单个对象或多个对象至API
修订 Delphi 2006 启动失败的错误
Notepad++配置masm32汇编环境
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服