将 Delphi 形式转换为 Lazarus 时出现问题

发布于 2024-08-11 23:05:51 字数 1125 浏览 6 评论 0原文

在我将 Delphi Windows 服务应用程序移植到 FPC Linux 控制台应用程序后,我尝试使用 GUI 移植程序。我在我的 Windows 机器上安装了最新的 Lazarus 并转换了简单的“hello world”应用程序。一个单元具有表单(Delphi 中的 .dfm 文件)。 Lazarus 将该表单转换为 .lfm 和 .lrs 文件。但是编译此文件时存在问题:

windres: C:/htlib/pas/FInfo.lrs:1: syntax error
Free Pascal Compiler version 2.2.4 [2009/10/25] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Win32 for i386
Compiling lazarus_test.lpr
...
Compiling C:\htlib\pas\FInfo.pas
Compiling resource C:\htlib\pas\FInfo.lrs
d:\lazarus\fpc\2.2.4\bin\i386-win32\windres.exe: C:/htlib/pas/FInfo.lrs:1: syntax error
C:\htlib\pas\FInfo.pas(366,1) Error: Error while linking
C:\htlib\pas\FInfo.pas(366,1) Fatal: There were 1 errors compiling module, stopping

FInfo.lrs 文件的第一行看起来像文本文件(不是二进制的 .res 文件):

{ This is an automatically generated lazarus resource file }

LazarusResources.Add('TfrmInfo','FORMDATA',[
  'TPF0'#8'TfrmInfo'#7 ...

在设计器中我可以看到并编辑此表单,所以我认为它已成功转换。 也许 .lrs 文件有问题?它不应该是二进制的 .res 文件吗? 我应该做什么来编制这个表格?

编辑

我的 .pas 单元的形式如下:

{$R *.lrs}

After I ported Delphi Windows service app to FPC Linux console app I tried to port program with GUI. I installed newest Lazarus on my Windows machine and converted simple "hello world" app. One unit has form (.dfm file in Delphi). This form was converted to .lfm and .lrs files by Lazarus. But there is problem with compiling this:

windres: C:/htlib/pas/FInfo.lrs:1: syntax error
Free Pascal Compiler version 2.2.4 [2009/10/25] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Win32 for i386
Compiling lazarus_test.lpr
...
Compiling C:\htlib\pas\FInfo.pas
Compiling resource C:\htlib\pas\FInfo.lrs
d:\lazarus\fpc\2.2.4\bin\i386-win32\windres.exe: C:/htlib/pas/FInfo.lrs:1: syntax error
C:\htlib\pas\FInfo.pas(366,1) Error: Error while linking
C:\htlib\pas\FInfo.pas(366,1) Fatal: There were 1 errors compiling module, stopping

First lines of FInfo.lrs file which looks like text file (not binary as .res files):

{ This is an automatically generated lazarus resource file }

LazarusResources.Add('TfrmInfo','FORMDATA',[
  'TPF0'#8'TfrmInfo'#7 ...

In designer I can see and edit this form, so I think it was converted with success.
Maybe there is something wrong with .lrs file? Shouldn't it be binary as .res files?
What should I do to compile this form?

EDIT:

My .pas unit has this form as:

{$R *.lrs}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

脸赞 2024-08-18 23:05:51

删除任何杂散的 {$R *.res} 或 {$R *.lrs} 指令。

2.2.x fpc/lazarus 版本将 *.res 文件转换为 .lrs 文件,然后将其作为结构化常量包含在内。如果将 *.res 包含在实现点下方(如 Delphi 中),则独立添加 *.res 会导致此失败。正确的 *.lrs 包含点位于初始化部分。

只有 2.4.x(RC1 已发布)将具有基于 {$R *.res} 的“真实”资源支持。但这可能需要几个月的时间才能完成(0.9.30)

Remove any stray {$R *.res} or {$R *.lrs} directives.

2.2.x fpc/lazarus versions transform *.res files to .lrs files that are then included as structured constants. Adding *.res independantly produces this fail if included just below the implementation point, like in Delphi. The proper *.lrs inclusion point is in the initialization section.

Only 2.4.x (RC1 is out) will have "real" resource support base on {$R *.res}. but that will probably take a few months to trickle through (0.9.30)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文