[fpc-pascal] Cross compiling Windows to arm-linux

Carsten Bager carsten at beas.dk
Tue Jul 23 10:21:18 CEST 2013


For some years ago I had a similar problem.
I solved it by forcing the use of specific libs.
See my old test programme below.
Carsten




> lcd_test.dpr: warning: 31: "crti.o" not found, this will probably cause a linking failure
> lcd_test.dpr: warning: 31: "crtbegin.o" not found, this will probably cause a linking failure
> lcd_test.dpr: warning: 31: "crtend.o" not found, this will probably cause a linking failure
> lcd_test.dpr: warning: 31: "crtn.o" not found, this will probably cause a linking failure



program testthreads;
{$mode objfpc}
{$RANGECHECKS ON}
{$OVERFLOWCHECKS ON}
{$S+ STACK CHECKING ON}
{$SMARTLINK ON}
{$TYPEINFO ON}
{$LONGSTRINGS OFF}
uses
  cthreads,
  sysutils,
  dos;

{$IFDEF ARM9LINUX}
  {$IFDEF Ulibc}
    {$linklib ulibc}                {Force use of uLibC}
    {$linklib gcc_s}                {Force use of gcc_s}
    {$linklib pthread}       {Force use of pthread-0.9.27}
    {$DEFINE IO_WORKAEAROUND}
  {$ENDIF}
{$ENDIF}

const
  threadcount = 10;
var
  finished : longint;
  ta:array[1..threadcount] of LongWord;

(*
{$I-}    {Input/output checking}
Function FileExists(s:shortstring):integer;
var
  f:file;
  mvi:integer;
Begin
  assign(f,s);
  reset(f);
  FileExists:=ioResult;
  close(f);
  mvi:=ioResult;
End;
{$I+}    {Input/output checking}
*)
(*
Function FileExists(s:shortstring):boolean;
Begin
    Exec('/bin/ls',s+'>NULL');
    FileExists:=Lo(DosExitCode)=0;
End;
  *)

function fu(p : pointer) : longint;
Var
  f:file;
Begin
  finished:=succ(finished);
  Writeln('thread ',finished,' started');
  assign(f,IntToStr(finished));
  rewrite(f);
  close(f);
  sleep(1000+finished*1000);
  Writeln('thread ',finished,' stopped');
  finished:=pred(finished);
End;

var
  i : longword;
  b:boolean;
Begin
  WriteLn('<0>',paramstr(0));
  WriteLn('<1>',paramstr(1));
  WriteLn('<2>',paramstr(2));
  WriteLn('<E>',GetEnv('USER'));
  WriteLn(fileExists('1'));
  WriteLn(fileExists('11'));
  finished:=0;
  for i:=1 to threadcount do
  begin
    BeginThread(@fu,nil,ta[i]);
  end;
  sleep(1000);
  while finished>0 do;
  Writeln(finished);
  try
  b:=fileExists('1');
  except
    WriteLn('-------------------');
  end;
  WriteLn(b);
  try
  b:=fileExists('11');
  except
    WriteLn('-------------------');
  end;
  WriteLn(b);
End.




More information about the fpc-pascal mailing list