[Lazarus] Cross-compiling for Raspberry Pi2

Sven Barth pascaldragon at googlemail.com
Thu Sep 24 08:04:26 CEST 2015


Am 24.09.2015 05:24 schrieb "Bo Berglund" <bo.berglund at gmail.com>:
>
> On Wed, 23 Sep 2015 17:48:24 -0400, Bo Berglund
> <bo.berglund at gmail.com> wrote:
> I added code into the DoRun procedure of the new project so it looks
> like this:
> [code]
> procedure TSSCommTest.DoRun;
> var
>   FComm: TIdTCPClient;
>   T1, T2: Cardinal;
> begin
>   { add your program here }
>   Writeln('Creating TCP client');
>   FComm := TIdTCPClient.Create;
>   try
>     Writeln('Connecting to 10.0.0.7 on port 2401 (CVS)');
>     T1 := GetTickCount;
>     FComm.Connect('10.0.0.7', 2401);
>     T2 := GetTickCount;
>     T2 := T2 - T1;
>     Writeln('Connection succeeded in ' + IntToStr(T2) + ' ms, now
> closing down');
>   finally
>     if FComm.Connected then
>        FComm.Disconnect;
>     FComm.Free;
>   end;
>   // stop program loop
>   Writeln('End of run');
>   Terminate;
> end;
> [/code]
> It compiled fine after I added Windows (for GetTickCount) and
> IdTCPClient to the uses clause.

Since you plan to port to Linux a word of caution: the "Windows" unit
doesn't exist there (and "GetTickCount" does neither), so you either need
to use platform specific functionality from the "BaseUnix" unit or cross
platform one from "SysUtils" and friends.
You should maybe also tale a look into using conditional compilation using
"$ifdef" and the defines the compiler already provides for you (e.g.
"windows", "linux", "unix", "cpui386", "cpuarm", etc.).
Note: in 3.0.0 TThread provides the cross platform class functions
TThread.GetTickCount and TThread.GetTickCount64.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150924/b6bef0fa/attachment-0003.html>


More information about the Lazarus mailing list