秋·风

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
lazarus交叉编译riscv64应用时自带的memdataset/lazreporr等控件如果使用到formeditingintf.pas时链接时出现出类以下提示的错误:

这是fpc引起的问题,也提交给lazarus/fpc官方,不知道啥能修复(希望官方尽快修复这个Bug)。
以下是网友英分享的修复方法(但本方法部分控件还存在链接问题,可参照这个方法修复如fastreport),常用的控件已可正常编译运行,基本满足用lazarus编写riscv64的应用需求。
打开lazarus\components\ideintf\formeditingintf.pas

添加红色代码:

{
 *****************************************************************************
  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************

  Author: Shane Miller, Mattias Gaertner

  Abstract:
    Methods to access the form editing of the IDE.
}
unit FormEditingIntf;

{$mode objfpc}{$H+}

interface

uses
  Classes, TypInfo, types, Math,
  // LCL
  LCLClasses, Forms, Controls,
  // LazUtils
  CompWriterPas, LazLoggerBase,
  // IdeIntf
  ComponentEditors, ObjectInspector, UnitResources;
  
const
  ComponentPaletteImageWidth = 24;
  ComponentPaletteImageHeight = 24;
  ComponentPaletteBtnWidth  = ComponentPaletteImageWidth + 3;
  ComponentPaletteBtnHeight = ComponentPaletteImageHeight + 3;
  DesignerBaseClassId_TForm = 0;
  DesignerBaseClassId_TDataModule = 1;
  DesignerBaseClassId_TFrame = 2;
  NonControlProxyDesignerFormId = 0;
  FrameProxyDesignerFormId = 1;
{ $if not defined(cpuriscv64) }

type
  TDMCompAtPosFlag = (
    dmcapfOnlyVisible,
    dmcapfOnlySelectable
    );
  TDMCompAtPosFlags = set of TDMCompAtPosFlag;

  TDesignerMediator = class;

  INonFormDesigner = interface
  ['{244DEC6B-80FB-4B28-85EF-FE613D1E2DD3}']
    procedure Create;

    function GetLookupRoot: TComponent;
    procedure SetLookupRoot(const AValue: TComponent);
    property LookupRoot: TComponent read GetLookupRoot write SetLookupRoot;

    procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer);
    procedure Notification(AComponent: TComponent; AOperation: TOperation);
    procedure Paint;

    procedure DoSaveBounds;
    procedure DoLoadBounds;
  end;

  IFrameDesigner = interface(INonFormDesigner)
  ['{2B9442B0-6359-450A-88A1-BB6744F84918}']
  end;

  INonControlDesigner = interface(INonFormDesigner)
  ['{5943A33C-F812-4052-BFE8-77AEA73199A9}']
    function GetMediator: TDesignerMediator;
    procedure SetMediator(AValue: TDesignerMediator);
    property Mediator: TDesignerMediator read GetMediator write SetMediator;
  end;

  { TNonFormProxyDesignerForm }

  TNonFormProxyDesignerForm = class(TForm{$if not defined(cpuriscv64)}, INonFormDesigner{$endif})
  private
    FNonFormDesigner: INonFormDesigner;
    FLookupRoot: TComponent;
  protected
    procedure Notification(AComponent: TComponent; AOperation: TOperation); override;

    procedure SetLookupRoot(AValue: TComponent); virtual;
    function GetPublishedBounds(AIndex: Integer): Integer; virtual;
    procedure SetPublishedBounds(AIndex: Integer; AValue: Integer); virtual;
  public
    constructor Create(AOwner: TComponent; ANonFormDesigner: INonFormDesigner); virtual; reintroduce;
    destructor Destroy; override;
    procedure Paint; override;
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
    procedure SetDesignerFormBounds(ALeft, ATop, AWidth, AHeight: integer);
    procedure SetPublishedBounds(ALeft, ATop, AWidth, AHeight: integer);
    procedure SetLookupRootBounds(ALeft, ATop, AWidth, AHeight: integer); virtual;
    function DockedDesigner: boolean; virtual;

    property NonFormDesigner: INonFormDesigner read FNonFormDesigner {$if not defined(cpuriscv64)} implements INonFormDesigner{$endif};
    property LookupRoot: TComponent read FLookupRoot write SetLookupRoot;
  published
    property Left: Integer index 0 read GetPublishedBounds write SetPublishedBounds;
    property Top: Integer index 1 read GetPublishedBounds write SetPublishedBounds;
    property Width: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
    property Height: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
    property ClientWidth: Integer index 2 read GetPublishedBounds write SetPublishedBounds;
    property ClientHeight: Integer index 3 read GetPublishedBounds write SetPublishedBounds;
  end;

  { TFrameProxyDesignerForm }

  TFrameProxyDesignerForm = class(TNonFormProxyDesignerForm{$if not defined(cpuriscv64)}, IFrameDesigner{$endif})
  private
    function GetFrameDesigner: IFrameDesigner;
  public
    property FrameDesigner: IFrameDesigner read GetFrameDesigner{$if not defined(cpuriscv64)}implements IFrameDesigner{$endif};
  end;

  { TNonControlProxyDesignerForm }

  TNonControlProxyDesignerForm = class(TNonFormProxyDesignerForm{$if not defined(cpuriscv64)}, INonControlDesigner{$endif})
  private
    FMediator: TDesignerMediator;
    function GetNonControlDesigner: INonControlDesigner;
  protected
    procedure SetMediator(AValue: TDesignerMediator); virtual;
  public
    property NonControlDesigner: INonControlDesigner read GetNonControlDesigner{$if not defined(cpuriscv64)} implements INonControlDesigner{$endif};
    property Mediator: TDesignerMediator read FMediator write SetMediator;
  end;

  TNonFormProxyDesignerFormClass = class of TNonFormProxyDesignerForm;

最后重新编译lazarus(不重新编译也没问题)
这是用unidac+sqlite编译的Demo:


lazareport在riscv64运行:

 

fstreport在riscv64运行:

 

posted on 2024-09-12 14:48  秋·风  阅读(94)  评论(0编辑  收藏  举报