DBMNG数据库管理与应用

书籍是全世界的营养品。生活里没有书籍,就好像没有阳光;智慧里没有书籍,就好像鸟儿没有翅膀。
当前位置:首页 > 经验分享 > Delphi

LinuxLazarus下安装indy10的方法

一、首次安装方法:

1.解压indy,拷贝文件夹到usr/lib/lazarus/Components

2.打开文件夹中的/lazarus/indylaz.lpk

3.添加indy\fpc文件夹中的IdGlobal.pas和IdStreamVCL.pas两个文件

4.编译安装。

二、如果首次没按照上面的安装方法,安装失败后,重新按照上面方法同样会提示下面错误

Recompiling IdStreamVCL, checksum changed for IdGlobal
IdStreamVCL.pas(10,10) Fatal: Can't find unit IdStreamVCL used by IdStream

这时候,需要将下面路径中的  IdGlobal.* 、 IdStreamVCL .*、 IdStream .*、以及其他IdXXXX.*删除

/usr/lib/lazarus/units/i386-linux

删除后,再按照首次安装方法进行安装即可。

注:

Fatal: Can not find IdStreamVCL used by IdStream 错误的解决办法

因为之前会报

Recompiling IdStreamVCL, checksum changed for IdGlobal

Unable to find file "IDStreamVCL.pas".这个错误。

这里只是简单的解决此类错误,也可以尝试其他方式进行修改:
http://www.lazarus.freepascal.org/index.php?topic=8813.0
 
修改了IDStreamVCL.pas,内容如下,重新编译即可正常使用Indy10控件
{
  $Project$
  $Workfile$
  $Revision$
  $DateUTC$
  $Id$
  This file is part of the Indy (Internet Direct) project, and is offered
  under the dual-licensing agreement described on the Indy website.
  (http://www.indyproject.org/)
  Copyright:
   (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}
{
  $Log$
}
unit IdStreamVCL;
interface
{$I IdCompilerDefines.inc}
uses
  Classes;
type
  TIdBytes = array of Byte;
  TIdStreamHelperVCL = class
  public
    class function ReadBytes(
          const AStream: TStream;
          var VBytes: TIdBytes;
          const ACount: Integer = -1;
          const AOffset: Integer = 0) : Integer; {$IFDEF DOTNET} static; {$ENDIF}
    class function Write(
          const AStream: TStream;
          const ABytes: TIdBytes;
          const ACount: Integer = -1;
          const AOffset: Integer = 0) : Integer; {$IFDEF DOTNET} static; {$ENDIF}
    class function Seek(
          const AStream: TStream;
          const AOffset: Int64;
          const AOrigin: TSeekOrigin) : Int64; {$IFDEF DOTNET} static; {$ENDIF}
  end;
  function IndyLength(const ABuffer: TIdBytes; const ALength: Integer = -1; const AIndex: Integer = 0): Integer;
  function IndyMax(const AValueOne, AValueTwo: Integer): Integer;
  function IndyMin(const AValueOne, AValueTwo: Integer): Integer;
implementation
function IndyMin(const AValueOne, AValueTwo: Integer): Integer;
{$IFDEF USEINLINE}inline;{$ENDIF}
begin
  if AValueOne > AValueTwo then begin
    Result := AValueTwo;
  end else begin
    Result := AValueOne;
  end;
end;
function IndyMax(const AValueOne, AValueTwo: Integer): Integer;
{$IFDEF USEINLINE}inline;{$ENDIF}
begin
  if AValueOne < AValueTwo then begin
    Result := AValueTwo;
  end else begin
    Result := AValueOne;
  end;
end;
function IndyLength(const ABuffer: TIdBytes; const ALength: Integer = -1; const AIndex: Integer = 0): Integer;
{$IFDEF USEINLINE}inline;{$ENDIF}
var
  LAvailable: Integer;
begin
  Assert(AIndex >= 0);
  LAvailable := IndyMax(Length(ABuffer)-AIndex, 0);
  if ALength < 0 then begin
    Result := LAvailable;
  end else begin
    Result := IndyMin(LAvailable, ALength);
  end;
end;
// RLebeau: must use a 'var' and not an 'out' for the VBytes parameter,
// or else any preallocated buffer the caller passes in will get wiped out!
class function TIdStreamHelperVCL.ReadBytes(const AStream: TStream; var VBytes: TIdBytes;
  const ACount, AOffset: Integer): Integer;
var
  LActual: Integer;
begin
  Assert(AStream<>nil);
  Result := 0;
  if VBytes = nil then begin
    SetLength(VBytes, 0);
  end;
  //check that offset<length(buffer)? offset+count?
  //is there a need for this to be called with an offset into a nil buffer?
  LActual := ACount;
  if LActual < 0 then begin
    LActual := AStream.Size - AStream.Position;
  end;
  //this prevents eg reading 0 bytes at Offset=10 from allocating memory
  if LActual = 0 then begin
    Exit;
  end;
  if Length(VBytes) < (AOffset+LActual) then begin
    SetLength(VBytes, AOffset+LActual);
  end;
  Assert(VBytes<>nil);
  Result := AStream.Read(VBytes[AOffset], LActual);
end;
class function TIdStreamHelperVCL.Write(const AStream: TStream; const ABytes: TIdBytes;
  const ACount: Integer; const AOffset: Integer): Integer;
var
  LActual: Integer;
begin
  Result := 0;
  Assert(AStream<>nil);
  //should we raise assert instead of this nil check?
  if ABytes <> nil then begin
    LActual := IndyLength(ABytes, ACount, AOffset);
    // TODO: loop the writing, or use WriteBuffer(), to mimic .NET where
    // System.IO.Stream.Write() writes all provided bytes in a single operation
    if LActual > 0 then begin
      Result := AStream.Write(ABytes[AOffset], LActual);
    end;
  end;
end;
class function TIdStreamHelperVCL.Seek(const AStream: TStream; const AOffset: Int64;
  const AOrigin: TSeekOrigin): Int64;
{$IFNDEF SIZE64STREAM}
const
  cOrigins: array[TSeekOrigin] of Word = (soFromBeginning, soFromCurrent, soFromEnd);
{$ENDIF}
begin
  {$IFDEF SIZE64STREAM}
  Result := AStream.Seek(AOffset, AOrigin);
  {$ELSE}
  Result := AStream.Seek(AOffset and $FFFFFFFF, cOrigins[AOrigin]);
  {$ENDIF}
end;
end.


本站文章内容,部分来自于互联网,若侵犯了您的权益,请致邮件chuanghui423#sohu.com(请将#换为@)联系,我们会尽快核实后删除。
Copyright © 2006-2023 DBMNG.COM All Rights Reserved. Powered by DEVSOARTECH            豫ICP备11002312号-2

豫公网安备 41010502002439号