如何制作第三方组件的DCU文件,而不在应用程序目录中生成? [英] How do I make third party component's DCU files, not to get generated in my application directory?

查看:188
本文介绍了如何制作第三方组件的DCU文件,而不在应用程序目录中生成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Delphi中,每当我重建应用程序时,都会在可执行文件所在的应用程序目录中生成所有第三方组件的DCU文件。

如何更改此行为?

,这样就不会在我的应用程序目录中生成第三方组件的DCU文件。

In my Delp whenever I rebuild my application, all 3rd party component's DCU files are getting generated in my application's directory, where the executable resides.
How do I change this behaviour?
So that third party component's DCU files won't get generated in my application directory.

推荐答案

编译器生成的所有文件都创建在同一目录中。因此,无法将生成的.dcu文件文件放入不同的目录中,并将第三方库文件与源文件中的文件分开。

The .dcu files that the compiler generates are all created in the same directory. So there's no way to put generated .dcu files files into different directories and separate those from third party libraries from those from your source files.

但是,通常这是一个坏主意将.dcu文件放入与源文件相同的目录中。那只会使事情变得混乱。最佳实践是将.dcu文件放入项目的子目录中。编译器选项使您可以执行此操作。打开编译器选项对话框,然后将目标下拉菜单更改为所有配置-所有平台。这是您其他配置继承自的基本配置。对话框如下所示:

However, it's generally a bad idea to put the .dcu files into the same directory as the source files. That just clutters things up. Best practise is to put the .dcu files into a sub-directory of your project. The compiler options let you do this. Open up the compiler options dialog and change the target drop down to All configurations - All platforms. This is the base configuration that you other configurations inherit from. The dialog looks like this:

您需要更改的设置是 Unit输出目录。上图显示了XE2上新项目的默认设置。值 .\ $(平台)\ $(配置)由编译器扩展。因此,如果要针对Win32平台构建调试配置,则.dcu文件将输出到 .\Win32\Debug

The setting you need to change is Unit output directory. The image above shows the default for a new project on XE2. The value .\$(Platform)\$(Config) is expanded by the compiler. So if you are building a debug config targeting the Win32 platform, your .dcu files will be output to .\Win32\Debug.

此处记录了编译器选项: http://docwiki.embarcadero.com / RADStudio / en / Delphi_Compiler

The compiler options are documented here: http://docwiki.embarcadero.com/RADStudio/en/Delphi_Compiler

单位输出目录的描述为:

The description of the unit output directory is:


指定一个单独的目录以包含 .dcu

另一个紧密相关的选项是输出目录。这是放置编译后的可执行文件的位置。如果您针对多个平台,那么您确实需要将此可执行文件放置在主项目目录之外的其他位置。否则,自动化构建将变得困难且容易出错。当您实际上想要64位可执行文件时,选择过时的32位可执行文件太容易了。

The other closely related option is the output directory. This is where the compiled executable file will be placed. If you are targeting multiple platforms then you really need to put this executable file somewhere other than the main project directory. Otherwise automating build becomes difficult and error prone. It's all too easy to pick up an out of date 32 bit executable when you actually want a 64 bit executable.

所以我对您的建议是使用默认值 .\ $(平台)\ $(配置),因为它是一个很好的默认值。

So my advice to you is to use the default of .\$(Platform)\$(Config) since it is an excellent default.

这篇关于如何制作第三方组件的DCU文件,而不在应用程序目录中生成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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