德尔福 DFM 未找到
我的项目中有一个 xyz.pas 文件引用。但那个文件不在我身边。我有该 xyz.pas 文件的 xyz.dcu 和 xyz.obj 文件。 当我尝试编译该项目时,出现错误“未找到 xyz.dcu”。所以我在搜索路径中包含了 xyz.dcu 的路径。现在我收到错误“未找到 xyz.dfm”。
请建议我解决方案。是否可以仅使用 .dcu 和 .obj 文件编译项目?
提前致谢。 问候, 纳伦
I am having one xyz.pas file reference in my project. But that file is not with me. I am having the xyz.dcu and xyz.obj file of that xyz.pas file.
When I tried to compile the project I have got the Error "xyz.dcu not found". So i have included the path of xyz.dcu in Search path. Now I am getting error "xyz.dfm not found".
Please suggest me the solution. Is it possible to compile the project with only .dcu and .obj files?
Thanks in advance.
Regards,
Naren
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我希望你没有失去你的工作。
简单来说,Delphi 的工作原理如下:
PAS+DFM =>都柏林城市大学
DCU+RES=>执行文件
有关 Delphi 文件的更多信息,请参见本答案的末尾。
如果您只有 DCU 文件,则可以编译该项目。首先,从文件夹中删除 PAS 文件,否则 Delphi 将尝试重新编译它(为了重新编译它,它需要 DFM 文件)。
我认为 Obj 文件对您没有任何用处。
DFM 文件对于您的项目非常非常重要,但并不是至关重要。如果您非常需要,您仍然可以不使用它,因为可以根据 PAS 文件中的信息以及应用程序 GUI 的外观(如果您曾经见过它运行)手动重建它。
技巧如下(涉及一些工作):
只需创建一个新表单,然后查看原始 PAS 文件的顶部以获取该表单的声明。它可能看起来像这样:
然后将所有这些控件放回到新表单中,并按照 PAS 文件中的名称(xLabel、yButton 等)准确命名它们。将它们排列为类似于原始 GUI。完成后,将新创建的 PAS 文件替换为原始 PAS 文件。重要提示:DFM 和 PAS 文件的名称应匹配。编译就完成了!重建的 GUI 可能看起来与原始 GUI 不完全一样,但它应该可以做到。
提示:
有一些工具可以从 DCU/EXE 中提取 DFM 文件。
以下是其中一些:www.delphi2.software.informer.com/download-delphi-extract-dfm
这会对你有很大帮助!
.PAS - Delphi 源文件
PAS 应存储在源代码管理中
在 Delphi 中,PAS 文件始终是单元或表单的源代码。单元源文件包含应用程序中的大部分代码。该单元包含附加到表单或其包含的组件的事件的任何事件处理程序的源代码。我们可以使用 Delphi 的代码编辑器编辑 .pas 文件。不要删除 .pas 文件。
.DCU - Delphi编译单元
已编译的单元 (.pas) 文件。默认情况下,每个单元的编译版本存储在一个单独的二进制格式文件中,该文件与单元文件同名,但扩展名为 .DCU(Delphi 编译单元)。例如,unit1.dcu 包含在unit1.pas 文件中声明的代码和数据。重建项目时,不会重新编译各个单元,除非它们的源 (.PAS) 文件自上次编译以来已发生更改,或者无法找到它们的 .DCU 文件。安全删除 .dcu 文件,因为 Delphi 在编译应用程序时会重新创建它。
.DFM - 德尔福表格
DFM 应存储在源代码管理中
这些文件始终与 .pas 文件配对。 Dfm 文件包含表单中所含对象的详细信息(属性)。通过右键单击表单并从弹出菜单中选择“以文本形式查看”,可以将其以文本形式查看。 Delphi 将 .dfm 文件中的信息复制到完成的 .exe 代码文件中。更改此文件时应小心,因为对其进行更改可能会阻止 IDE 加载表单。表单文件可以以二进制或文本格式保存。通过“环境选项”对话框,您可以指定要为新创建的表单使用哪种格式。不要删除 .dfm 文件。
来源:delphi.about.com/od/beginners/a/aa032800a.htm
I hope you haven't lost your work.
Simplified, Delphi works like this:
PAS+DFM => DCU
DCU+RES => EXE
More about Delphi files at the end of this answer.
You can compile the project if you only have the DCU file. First, remove the PAS file from your folder else Delphi will try to recompile it (and in order to recompile it, it needs the DFM file).
I don't think the Obj file will be of any use to you.
The DFM file is very very important for your project but yet not critical important. If you are in deep need, you can still go on without it as it can be reconstructed manually based on information you have in the PAS file and based on the way the application's GUI looks (if you have ever seen it running).
Here is the trick (involves some work):
Just create a new form and then look at the top of your original PAS file for the declaration of the form. It may look like this:
Then put all those controls back to your new form and name them exactly as they are named in the PAS file (xLabel, yButton, etc). Arrange them to resemble the original GUI. When done, replace the new created PAS file with your original PAS file. IMPORTANT: the name of the DFM and PAS file should match. Compile and you are done! The rebuilt GUI may not look EXACTLY as the original one, but it should do it.
Hint:
There are tools that can extract the DFM file from DCU/EXE.
Here are some of them: www.delphi2.software.informer.com/download-delphi-extract-dfm
This will help you a lot!
.PAS - Delphi Source File
PAS should be stored in Source Control
In Delphi, PAS files are always the source code to either a unit or a form. Unit source files contain most of the code in an application. The unit contains the source code for any event handlers attached to the events of the form or the components it contains. We may edit .pas files using Delphi's code editor. Do not delete .pas files.
.DCU - Delphi Compiled Unit
A compiled unit (.pas) file. By default the compiled version of each unit is stored in a separate binary-format file with the same name as the unit file, but with the extension .DCU (Delphi compiled unit). For example unit1.dcu contains the code and data declared in the unit1.pas file. When you rebuild a project, individual units are not recompiled unless their source (.PAS) files have changed since the last compilation, or their .DCU files cannot be found. Safely delete .dcu file because Delphi recreates it when you compile the application.
.DFM - Delphi Form
DFM should be stored in Source Control
These files are always paired with .pas files. Dfm file contains the details (properties) of the objects contained in a form. It can be view as text by right clicking on the form and selecting view as text from the pop-up menu. Delphi copies information in .dfm files into the finished .exe code file. Caution should be used in altering this file as changes to it could prevent the IDE from being able to load the form. Form files can be saved in either binary or text format. The Environment Options dialog lets you indicate which format you want to use for newly created forms. Do not delete .dfm files.
source: delphi.about.com/od/beginners/a/aa032800a.htm
如果您仍然拥有可执行文件,那么您可以通过任意资源管理器从应用程序资源中提取完整的原始 DFM 文件。例如:XN 资源编辑器。在RC DATA类别中,会有一个名为TXYZ的项目。
If you are still in the possesion of the executable, then you can extract your complete and original DFM file from the application resources by any arbitrary resource manager. For example: XN Resource Editor. In the RC DATA category, there will be an item called TXYZ.
德尔福20xx/XE
请注意,Delphi 将文件的旧版本保存在项目目录的隐藏子目录中,名为
__history
。该目录中保存着 .pas、.dfm 和其他项目文件的保存版本。
每次将更改保存到磁盘时都会创建这些文件。
在硬盘上搜索名为
*.~*~
的所有文件(包括隐藏文件),这应该会显示您可能拥有的所有备份源文件。他们会怀念您最后所做的更改,但至少您不必重新做所有事情。
Delphi 7 及更早版本
Delphi 7 将这些文件保存在与项目文件相同的目录中,并带有
.~
扩展名。Delphi 20xx/XE
Note that Delphi saves old versions of your files in a hidden subdir of your project dir called
__history
.In that dir are saved versions of your .pas, .dfm and other project files.
These files are created every time you save a change to disk.
Do a search on your harddisk for all files, (including hidden ones) named
*.~*~
this should bring up any backup source files you may have.They will miss the last change(s) you made, but at least you will not have to do everything all over again.
Delphi 7 and before
Delphi 7 saves these files in the same dir as your project files with a
.~
extension.DFM 文件保存(例如)表单的“视觉”方面(控件、组件、属性、视觉效果、数据...)。如果 PAS 文件(或编译后的 DCU 文件)需要 DFM,则必须拥有它,否则会出现此错误。我认为除了 DFM 之外别无他法。
更正(如下所述,抱歉!):如果您删除 PAS 文件并仅提供 DCU 文件,则您可以仅使用 DCU 文件进行编译。在这种情况下,DCU 文件必须使用相同的编译器版本进行编译才能链接到应用程序中,因为编译器无法重新编译 DCU。
DFM-Files hold the "visual" aspects (controls, components, properties, visuals, data...) of a (say) form. If the PAS-File (or the compiled DCU-File) needs the DFM, you have to have it, or you get this error. There is no other way than to have the DFM, i think.
Correction (as written below, sorry!): you can compile with only the DCU-file if you remove the PAS-file and provide ONLY the DCU-File. In this case the DCU-File must be compiled with the same compiler-version to be linked into the App, because the compiler can not recompile the DCU.
虽然已经很晚了,但这就是我带来的。
我的目录结构是这样的
在 /Project 文件夹中,我创建了一个名为“dfmcopy.bat”的 .bat 文件,
它包含的所有内容是
然后,在我的 .bpl 的构建后事件中
这将递归复制包含在中的所有 .dfm将 /Source 文件夹复制到 /Library/{DelphiVersion}/{Platform}/{Config} 文件夹中
需要注意的是,如果您有多个具有此构建后事件的项目,则可能会复制 dfms每个项目都一遍又一遍。不知道现在是否会造成任何问题。
This is pretty late, but here's what I came with.
My directory stucture is like this
In the /Project folder, i created a .bat file named 'dfmcopy.bat'
All it contains is
Then, in my post build event for my .bpl
This will recursively copy all .dfm that are contained in the /Source folder into the /Library/{DelphiVersion}/{Platform}/{Config} folder
One caveat is that if you have multiple projects that have this post build event, dfms might be copied over and over for each project. Don't know if that can pose any issue now.
我使用 apache ant 构建 delphi 项目。
我通过删除所有 dcu 文件并将编译器输出文件与源文件分开来修复“dfm 未找到错误”。
该问题可能是由于 dcus 文件路径错误引起的。
I use apache ant to build delphi project.
I fix the "dfm not found error" by deleting all dcu files and seperating compiler output files from source files.
The problem is probabily caused by wrong path of dcus files.