简体   繁体   English

Delphi7中如何安装Tntcontrols

[英]How to install Tntcontrols in Delphi7

I am new to Delphi, I need TntContols package in my project, Download TntContols in https://github.com/pitfiend/TntControls , the install TntUnicode-master\\Delphi\\d7TntUnicodeVcl_D70.dpk , then I drag a TntButton into the form, and Run my application, but error throw:我是 Delphi 新手,我的项目中需要 TntContols 包,在https://github.com/pitfiend/TntControls下载 TntContols ,安装TntUnicode-master\\Delphi\\d7TntUnicodeVcl_D70.dpk ,然后我拖一个 TntButton 到表单中,并运行我的应用程序,但错误抛出:

[Fatal Error] Unit1.pas(7): File not found: 'TntStdCtrls.dcu'

code below:代码如下:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, TntStdCtrls;

type
  TForm1 = class(TForm)
    btn1: TTntButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.

By default, the BPL and DCU files that come with D7 are installed in the .LIB and .BIN folders, respectively, below the main Delphi folder, which I'll refer to as \\D7.默认情况下,D7 附带的 BPL 和 DCU 文件分别安装在 Delphi 主文件夹下的 .LIB 和 .BIN 文件夹中,我将其称为 \\D7。

It's best not to install other components to those folders.最好不要将其他组件安装到这些文件夹中。 The reason is that eventually, as you install extra 3rd party libraries, you are likely to run into a compilation error "Unit Y was compiled with a different version of unit Y" which may require you to re-install Delphi if files in the BIN and LIB folders are involved.原因是最终,当您安装额外的 3rd 方库时,您可能会遇到编译错误“Unit Y 是用不同版本的 unit Y 编译的”,这可能需要您重新安装 Delphi,如果 BIN 中有文件和 LIB 文件夹都涉及到。 Actually, this problem usually arises after you've compiled a project which is configured so that it needlessly has access to the library's .PAS files (because the IDE does not need access to the libary's .PAS during compilation of a project which uses the library, as long as it can find the library's .DCU files).实际上,这个问题通常是在你编译了一个项目后出现的,只要它能找到库的 .DCU 文件)。

Many 3rd party libraries include (at least) two .DPK files, one of which is a so-called runtime package and the other is a design-time package.许多 3rd 方库包括(至少)两个 .DPK 文件,其中一个是所谓的运行时包,另一个是设计时包。 The design-time package is the one you install in the IDE to install the library's components and the run-time package contains routines which those in the design-time package depend on.设计时包是您在 IDE 中安装的用于安装库组件的包,运行时包包含设计时包中的例程所依赖的例程。 Unless a project which uses the libary is compiled to use runtime packages, the runtime package is not used in the process of compiling the project (but the counterpart .DCU files will be, which is why the IDE needs to be configured to find them).除非使用 libary 的项目被编译为使用运行时包,否则在编译项目的过程中不会使用运行时包(但对应的 .DCU 文件将是,这就是为什么需要配置 IDE 才能找到它们) .

What I've always done for 3rd party D7 libraries which don't have their own installer is as follows:我一直为没有自己的安装程序的 3rd 方 D7 库所做的如下:

  1. One-time only: Create a folder \\D7\\LIB2.一次性:创建一个文件夹\\D7\\LIB2。 Add it to your OS Path.将其添加到您的操作系统路径。

  2. For each .DPK file in the library you wish to install:对于要安装的库中的每个 .DPK 文件:

    a.一种。 Open the .DPK file in the IDE and edit its BPL and DCU output folders to \\D7\\LIB2.在 IDE 中打开 .DPK 文件并将其 BPL 和 DCU 输出文件夹编辑为 \\D7\\LIB2。 Do this by clicking the Options button in the Package editor and in the Project Options pop-up, on the Directories/Conditionals tab, set the Output Directory, Units Output Directory and DCP Output Directory all to \\D7\\LIB2为此,请单击包编辑器中的Options按钮,并在项目选项弹出窗口中的Directories/Conditionals选项卡上,将输出目录、单元输出目录和 DCP 输出目录全部设置为\\D7\\LIB2

    b.Compile the package by clicking the Compile button, then install it in the IDE by clicking the Install button if it's enabled.单击Compile按钮编译包,然后单击Install按钮(如果已启用)将其安装在 IDE 中。

    c. C。 Close the Package (.DPK) editor.关闭包 (.DPK) 编辑器。

  3. Open your project which is to use the library and edit its search path to include \\D7\\LIB2 but NOT the path to the library's .PAS files.打开要使用库的项目并编辑其搜索路径以包含 \\D7\\LIB2 但不是库的 .PAS 文件的路径。

  4. Compile your project.编译你的项目。

Notes:笔记:

Notice that the abouve does NOT include adding the path to the source (.PAS files) of the library to your project.请注意,以上不包括将库的源(.PAS 文件)的路径添加到您的项目中。 Doing so is unnecessary if you follow the above steps and only likely to lead (eventually) to the occurrence of the "Unit Y was compiled ..." error I mentioned.如果您按照上述步骤操作,那么这样做是不必要的,并且只会(最终)导致出现我提到的“Unit Y was connected ...”错误。

The above method also works with recent Delphi versions, though involves more clicking around to do the necessary since the stand-alone .DPK editor was removed from the IDE.上述方法也适用于最新的 Delphi 版本,但由于独立的 .DPK 编辑器已从 IDE 中删除,因此需要更多的点击来执行必要的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM