build和compile的区别[编程语言]

来源:互联网 发布:用源码建网站 编辑:程序博客网 时间:2024/06/04 18:14

最近想到一个问题,在写完代码之后运行之前需要编译一下,但是还有一个build功能,这两个到底有没有区别呢?


网上查了一下,buid比compile强大一点。运行的时候就知道,时间是不一样的。有人用过下面的方程式:

  BUILD = COMPILE   +   LINK   =   RESULT   IS   EXE  
  COMPILE   =   COMPILE   =   RESULT   IS   DCU

不管这个说法对不对,但是build确实比compile做的要多啊,build付出的不亚于compile啊。

下面简单看下大家对这两个的区别的看法:

Build是从新编译所有和生成exe有关的文件,无论.pas文件是否修改过,它都会重新生成新的.dcu,并从新链接这些.dcu等等文件。   

Compile是编译修改过的文件,它只生成新修改过的.pas的相应的.dcu,并从新链接这些改变过的.dcu等等文件。

如果你感兴趣,还可以看下borland的官方解释吧:


Use Project|Compile project to compile all files in the current project that have changed since the last build into a new executable file,. dynamic link library (.DLL), resource file (.RES), or so on. This command is similar to the Build command, except that Project|Compile builds only those files that have changed since the last compile, whereas Build rebuilds all files whether they have changed or not. 


If you checked Show Compiler Progress from the Preferences page on the Tools|Environment Options dialog box, the Compiling dialog box displays information about the compilation progress and results. When your application successfully compiles, choose OK to close the Compiling dialog box.


If the compiler encounters an error, the product reports that error on the status line of the Code editor and places the cursor on the line of source code containing the error. 


The compiler builds executable files according to the following rules: 


The project (.dpr) file is always recompiled.
If the source code of a unit has changed since the last time the unit was compiled, the unit is compiled. When a unit is compiled, the product creates a file with a .dcu extension for that unit.


If Delphi cannot locate the source code for a unit, that unit is not recompiled.


If the interface part of a unit has changed, all the other units that depend on the changed unit are recompiled.
If a unit links in an object file (external routines), and the object file has changed, the unit is recompiled.
If a unit contains an Include file. and the Include file has changed, the unit is recompiled.


You may choose to compile only portions of your code if you use conditional directives and predefined symbols in your code.








Choose Build from the Project Manager Project context menu to rebuild all the components of your project regardless of whether they have changed.


This command is similar to Make except that Build rebuilds everything whereas Make rebuilds only those files that have been changed since the last build. 


Tip: This command is useful when you are unsure of exactly which files have or have not been changed, or when you simply want to ensure that all files are current and synchronized. It抯 also important to Build all files in a project when you抳e changed global compiler directives or compiler options, to ensure that all code compiles in the proper state.
Note: This command works the same as Project|Build project.
Tip: If you have multiple projects within a project group, you can make all projects within a project group by using the Project|Compile All Projects command.

原创粉丝点击