在 Delphi 中编译和构建有什么区别? [英] What is the difference between compiling and building in Delphi?

查看:21
本文介绍了在 Delphi 中编译和构建有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 Delphi-6,有两个选项:构建和编译.

With Delphi-6 there are two options: Build and Compile.

我知道当我运行程序时,它只编译已更改的文件,并为那些没有更改的文件使用 DCU.当我显然单击构建时,它会重建 DCU.

I know when I run a program it compiles only the files which have changed and uses the DCUs for those which haven't. When I click build apparently it rebuilds the DCUs.

我一直想知道的是,当我制作一个发布程序(更改构建设置、条件变量等)时,我可以直接编译,还是必须进行完整构建?

What I have been wondering is, when I make a program for release (changing build settings, conditional variables, etc.) can I just compile, or do I have to do a full build?

如果我不进行完整构建会发生什么,有什么后果吗?

What happens if I don't do a full build, is there any consiquence?

推荐答案

何时构建,何时编译?

仅当 .pas 源文件的日期时间戳更改 (1,2) 时,编译器才会自动重新编译单元.

The compiler only automatically recompiles units when the datetime stamp of the .pas source files changes (1,2).

在项目中的其他状态更改(指令、调试或其他编译器设置等)时,编译器不会自动重新编译.这就是你需要强制构建的时候.

On other state changes in the project (directives, debug or other compiler settings etc), the compiler won't automatically recompile. That's when you need to force a build.

当 .inc 或其他包含的 ($I) 文件更改 (3) 时,您还需要强制重建,因为它们的日期时间戳未被检查.

You also need to force a rebuild when .inc or other included ($I) files change(3), since their datetime-stamp is not checked.

总而言之,当单元 .pas 文件以外的任何内容发生变化时,您都需要进行构建.

So in summary, when anything but the unit .pas files changes, you need to do a build.

建筑中有一些奇怪的情况.大多数导致找不到单元xxx"错误,而它似乎在那里

There are some strange cases in building. Most result in a "can't find unit xxx" error while it appears to be there

  1. 一种是工程中单元的路径错误,或者工作目录错误时使用了相对路径.(请参阅 Delphi 调试错误的单元)
  2. (我不完全确定这个,这是一个假设)由于 CRC (1) 重新编译了 .dcu,但新编译的 dcu 被放置在不同的目录中.这对当前编译来说不是问题(因为已经加载了正确的 dcu),但是在随后的编译(例如依赖包)中,旧的 dcu 文件再次被找到,并且源不是 -> 错误.如有疑问,请始终通过递归删除所有 DCU 来清理构建目录
  3. 该单位在 .dpr 中的路径错误

(1) 如果 Delphi 就像 FPC,.dcu 包含它所依赖的所有 dcu 的接口部分的 CRC.这可用于检查是否还需要重新编译.例如.由于文件系统操作(移动 dcu 的左右)

(1) and if Delphi is like FPC, .dcu's contain a CRC of the interface section of all dcu's it depends on. This can be used to check if there is an additional need for recompiles too. E.g. due to filesystem manipulation (moving dcu's about)

(2) 高手们也看看 {$implicitbuild xx}

(2) for the experts, have a look at {$implicitbuild xx} too

(3) 与 Delphi 不同,FPC 确实在 .inc 更改时重建.FPC 项目在内部大量使用 .inc 文件,这一变化早在 Delphi 支持之前就已经存在.因此,将defines" inc 文件复制到任何目录中的包将无法使用 FPC 进行编译,因为它们的大小和 CRC 通常略有不同.Indy (10) 就是一个很好的例子.

(3) contrary to Delp FPC does rebuild on .inc changes. The FPC project heavily uses .inc files internally, this change already dates from before there was Delphi support. As a result, packages that copy the "defines" inc file into any directory won't compile with FPC because they have usually slightly different size and CRC. Indy (10) is a good example of this.

这篇关于在 Delphi 中编译和构建有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆