Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-10

Re: FPC on ARM (eg Zaurus)

25 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Florian Klaempfl
to Den Jean: Cross-compile for ARM: ============== I'd like to develop an application on Zaurus (arm)…
Den Jean wrote 50 lines
Hi, Cross-compile for ARM: ============== I'd like to develop an application on Zaurus (arm) with FPC, but I do not manage to create a cross-compile setup. Qt/Embedded binding for FPC: ================== I already created a binding for FPC to Qt/Embedded that works with libqte (the Qt/Embedded library) on Intel (under qvfb) I did not have time yet to put it on Sourceforge, but you can get a binary libqteintf + pascal sources on: http://users.pandora.be/Jan.Van.hijfte/qtforfpc/qtedemo.html Compile errors in fpc/compiler/arm: ======================= With the latest cvs (20 Oct 2004) I get the error below make clean all OS_TARGET=linux CPU_TARGET=arm BINUTILSPREFIX=arm-linux- --------------------------------------------------------------------------------------------------- ..fpc/compiler/ppc -darm -dGDB -dBROWSERLOG -dNOOPT -Xs -OG2p3 -n -Fuarm -Fusystems -Fu/other/storage/progs/fpcarm/fpc/rtl/linux -Fiarm -FE. -dRELEASE pp.pas cpubase.pas(511,59) Fatal: Syntax error, "," expected but ")" found --------------------------------------------------------------------------------------------------- When I fix this by adding a OS_NO to subreg2cgsize (do not know what I am doing :-) the compilation continues and stops with: --------------------------------------------------------------------------------------------------- cpupara.pas(44,94) Error: Identifier not found "tvarargspara" --------------------------------------------------------------------------------------------------- So I fix this by adding 'parabase' to the uses clause of cpupara.pas Then I get the following compile error: --------------------------------------------------------------------------------------------------- cpupara.pas(41,20) Error: There is no method in an ancestor class to be overridden: "tarmparamanager.getintparaloc(tproccalloption, LongInt):<record type>" ---------------------------------------------------------------------------------------------------

The current cvs is broken for ARM, it will be fixed after the current rewrites are finished.

* Does anyone have a working ARM snapshot ?

ftp://ftp.freepascal.org/fpc/snapshot/v19/linux-arm/fpc-1.9.3.arm.tar

* Or a FPC CVS date on which the ARM part compiles ? * I already tried 30 Jan 2003. The date on which the FPC news webpage announces that it works on Zaurus

The compiler from 5th April 2004 should work it's the date when that snapshot was generated.

Den Jean

Hi,

Cross-compile for ARM:
==============
I'd like to develop an application on Zaurus (arm) with FPC, but I do not manage to create a cross-compile setup.

Qt/Embedded binding for FPC:
==================
I already created a binding for FPC to Qt/Embedded that works with libqte (the Qt/Embedded library) on Intel (under qvfb)

I did not have time yet to put it on Sourceforge,
but you can get a binary libqteintf + pascal sources on:

http://users.pandora.be/Jan.Van.hijfte/qtforfpc/qtedemo.html

Compile errors in fpc/compiler/arm:
=======================

With the latest cvs (20 Oct 2004) I get the error below

make clean all OS_TARGET=linux CPU_TARGET=arm BINUTILSPREFIX=arm-linux-

--------------------------------------------------------------------------------------------------- ..fpc/compiler/ppc -darm -dGDB -dBROWSERLOG -dNOOPT -Xs -OG2p3 -n -Fuarm -Fusystems -Fu/other/storage/progs/fpcarm/fpc/rtl/linux -Fiarm -FE. -dRELEASE pp.pas
cpubase.pas(511,59) Fatal: Syntax error, "," expected but ")" found ---------------------------------------------------------------------------------------------------

When I fix this by adding a OS_NO to subreg2cgsize (do not know what I am doing :-)
the compilation continues and stops with:

--------------------------------------------------------------------------------------------------- cpupara.pas(44,94) Error: Identifier not found "tvarargspara" ---------------------------------------------------------------------------------------------------

So I fix this by adding 'parabase' to the uses clause of cpupara.pas

Then I get the following compile error:

--------------------------------------------------------------------------------------------------- cpupara.pas(41,20) Error: There is no method in an ancestor class to be overridden: "tarmparamanager.getintparaloc(tproccalloption, LongInt):<record type>"
---------------------------------------------------------------------------------------------------

* Does anyone have a working ARM snapshot ?
* Or a FPC CVS date on which the ARM part compiles ?
* I already tried 30 Jan 2003. The date on which the FPC news webpage announces that it works on Zaurus

kind regards,

Den Jean

Florian Klaempfl
to Den Jean: Hi Thanks. It works fine with the snapshot you pointed out. For a report see :…
Den Jean wrote 13 lines
On Thursday 21 October 2004 06:02 pm, Florian Klaempfl wrote: >>* Does anyone have a working ARM snapshot ? > >ftp://ftp.freepascal.org/fpc/snapshot/v19/linux-arm/fpc-1.9.3.arm.tar > Hi Thanks. It works fine with the snapshot you pointed out. For a report see : http://users.pandora.be/Jan.Van.hijfte/qtforfpc/SetupFPCCrossCompile.html

o) tar zxvf binutils.tar.gz
o) tar contains arm-linux-as arm-linux-ld
o) ln -s arm-linux-as as
o) ln -s arm-linux-ld ld
o) cd ..
o) echo "program hello; begin writeln('hello'); end." > hello.pas o) ppcarm -FD./binutils/ hello
o) my output was:

The "official" way is to do use -XP:
ppcarm -XParm-linux- hello
and install the arm-linux-as and arm-linux-ld into e.g. /usr/local/bin

Show quoted text 8 lines
kind regards, Den Jean _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Den Jean
to Florian Klaempfl: o) tar zxvf binutils.tar.gz o) tar contains arm-linux-as arm-linux-ld o) ln -s…
Florian Klaempfl wrote
The "official" way is to do use -XP: ppcarm -XParm-linux- hello and install the arm-linux-as and arm-linux-ld into e.g. /usr/local/bin

Nice. Webpage has been updated.
But the help of ppcarm -h does not show this option XP (if I checked correctly) Perhaps some docs I missed.
Thx for the arm compiler work.

ppcarm -h

-X executable options:
-Xc link with the c library
-Xs strip all symbols from executable
-XD try to link dynamic (defines FPC_LINK_DYNAMIC) -XS try to link static (default) (defines FPC_LINK_STATIC) -XX try to link smart (defines FPC_LINK_SMART)

kind regards,

Jan

Florian Klaempfl
to Den Jean
Den Jean wrote 8 lines
On Friday 22 October 2004 04:22 pm, Florian Klaempfl wrote: >The "official" way is to do use -XP: >ppcarm -XParm-linux- hello >and install the arm-linux-as and arm-linux-ld into e.g. /usr/local/bin Nice. Webpage has been updated.

What about putting these information into the fpc wiki?

But the help of ppcarm -h does not show this option XP (if I checked correctly)

Newer versions of FPC know about it.

Show quoted text 12 lines
Perhaps some docs I missed. Thx for the arm compiler work. ppcarm -h -X executable options: -Xc link with the c library -Xs strip all symbols from executable -XD try to link dynamic (defines FPC_LINK_DYNAMIC) -XS try to link static (default) (defines FPC_LINK_STATIC) -XX try to link smart (defines FPC_LINK_SMART)
Florian Klaempfl
to Den Jean
Den Jean wrote 8 lines
On Monday 25 October 2004 02:36 am, Florian Klaempfl wrote: >What about putting these information into the fpc wiki? > see my first wiki page on: http://www.freepascal.org/wiki/index.php/Setup_Cross_Compile_For_ARM

Thanks :)

Show quoted text 5 lines
linked by [Arm] (under development) http://www.freepascal.org/wiki/index.php/Platform_list If you have a better place than Platform List, just move it.

I've added some more links to it :)

Show quoted text 9 lines
kind regards, Den Jean _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Marco van de Voort
to Den Jean: I am trying to cross-compile a program a bit more complicated than Hello World and I have…
Show quoted text 9 lines
I am trying to cross-compile a program a bit more complicated than Hello World and I have the following problem. ppcarm uses the wrong libraries because it uses some default lib paths first before it uses the library paths added with -Fl eg: ppcarm -Sd -XParm-linux- -k'-z nodefaultlib' -vt -Fl/opt/Embedix/tools/arm-linux/lib* -Fl/opt/Embedix/tools/lib/gcc-lib/arm-linux/2.95.2 test_dl.pas

Try to add -Xd

Den Jean
to Florian Klaempfl: Thanks :) I've added some more links to it :)

Hi,

I am trying to cross-compile a program a bit more
complicated than Hello World and I have the following problem.

ppcarm uses the wrong libraries because it uses some default lib paths first before it uses the library paths added with -Fl

eg:

ppcarm -Sd -XParm-linux- -k'-z nodefaultlib' -vt -Fl/opt/Embedix/tools/arm-linux/lib* -Fl/opt/Embedix/tools/lib/gcc-lib/arm-linux/2.95.2 test_dl.pas

gives error:
/usr/lib/crti.o: could not read symbols: File in wrong format

which is true, /opt/Embedix/tools/arm-linux/lib/crti.o should be used

the -vt options tells me that /usr/lib is searched first.

Using library path: /lib/
Using library path: /usr/lib/
Using library path: /usr/X11R6/lib/
Using library path: /opt/Embedix/tools/arm-linux/lib/ .... etc ...

With -k'-z nodefaultlib' i tried in vain to omit searching for default libraries

============================
So, how can I tell ppcarm not to use /usr/lib ?
============================

When fiddling with LD_LIBRARY_PATH, I found out that the compiler programs ofcourse cannot cope with a library path to arm libs.

kind regards,
Den Jean

Den Jean
to Marco van de Voort: Try to add -Xd

Hi,

Marco van de Voort wrote
Try to add -Xd

Thanks, it does what I need. Did not find this in the manual nor in fpc -h.

*************
uses Dl;
*************

I managed to compile my qt binding for arm (the library is C/C++ code)
but to test fpc's capability of using it on arm I'd like to do stuff like
    Handle := dlopen(PChar(LibraryName), RTLD_NOW or RTLD_GLOBAL);
    Addr := dlsym (Handle, PChar(LibQteIntfFunctions [i]));
    if Addr = nil then writeln ('Function ''' + LibQteIntfFunctions[i] + ''' not found in library');

so I need to have a "USES dl" but a simple program like the following does not compile

==============
program small;
uses SysUtils,Dl;
begin
writeln ('Hello World');
end.
==============

ppcarm -Xd -Sd -XParm-linux- -Fl/opt/Embedix/tools/arm-linux/lib* -Fl/opt/Embedix/tools/lib/gcc-lib/arm-linux/2.95.2 small.pas Free Pascal Compiler version 1.9.3 [2004/04/05] for arm Copyright (c) 1993-2004 by Florian Klaempfl
Target OS: Linux for ARM
Compiling small.pas
Assembling small
Linking small
/usr/bin/arm-linux-ld: cannot find /lib/ld.so.1
small.pas(7) Error: Error while linking
Closing script ppas.sh

if I omit the linking stage (-Cn) Link.res contains ========
....
INPUT(
-ldl
/lib/ld.so.1
)
========
So I fix this by replacing /lib/ld.so.1 with /opt/Embedix/tools/arm-linux/lib/ld-2.2.2.so and compile with arm-linux-ld -o small link.res
The resulting program gives the following strange error

--------------------------------------------
./small[enter]
bash:./small: No such or directory
-------------------------------------------

But ./small really is there.

strace ./small gives:

----------------------------------------------------------- strace: exec: No such file or directory
execve("./small",["./small"],[/* 30 vars */]) = 0
-----------------------------------------------------------

Some any ideas ?

*************
uses Libc;
*************
I also need Libc.
But when compiling

----------------------------
program small;
uses SysUtils,libc;
begin
writeln ('Hello World');
end.
----------------------------

I get

---------------------------------------------------------------------------------------------------------------------------- arm-linux-ld: warning: cannot find entry symbol _start; defaulting to 000084c8 /usr/lib/fpc/1.9.3/cross/arm-linux/units/rtl/system.o: In function `SYSTEM_SYSTEM_EXIT': /usr/lib/fpc/1.9.3/cross/arm-linux/units/rtl/system.o(.text+0x147a8): undefined reference to `_haltproc' -----------------------------------------------------------------------------------------------------------------------------

So I add /usr/lib/fpc/1.9.3/cross/arm-linux/units/rtl/prt0.o to link.res (thank you Jose Pascual for this idea) Again this compiles but the resulting executable give the same ... "No such file or directory"...error as above.

Anyone any ideas left ???

kind regards,

Den Jean

Jonas Maebe
to Den Jean
Den Jean wrote 15 lines
----------------------------------------------------------------------- ----------------------------------------------------- arm-linux-ld: warning: cannot find entry symbol _start; defaulting to 000084c8 /usr/lib/fpc/1.9.3/cross/arm-linux/units/rtl/system.o: In function `SYSTEM_SYSTEM_EXIT': /usr/lib/fpc/1.9.3/cross/arm-linux/units/rtl/system.o(.text+0x147a8): undefined reference to `_haltproc' ----------------------------------------------------------------------- ------------------------------------------------------ So I add /usr/lib/fpc/1.9.3/cross/arm-linux/units/rtl/prt0.o to link.res (thank you Jose Pascual for this idea) Again this compiles but the resulting executable give the same ... "No such file or directory"...error as above.

I don't know whether this will fix the "no such file or directory" problem, but when linking to libc, you have to use cprt0.o instead of prt0.o

Also, what does "file <executable>" tell you? And "ldd <executable>"?

Jonas

Florian Klaempfl
to Den Jean: Thanks, it does what I need. Did not find this in the manual nor in fpc -h. *************…
Den Jean wrote
Anyone any ideas left ???

I built a new cross snapshot with all those issues fixed: ftp://ftp.freepascal.org/pub/fpc/snapshot/v19/linux-arm/fpc-cross-arm-linux.tar.gz

ppcarm tmt1 -XParm-linux- -Xd -Fl/usr/arm-linux/lib

created for me a working cross compiled test using dl (my emdebian libs are in /usr/arm-linux/):

hermes:~# ldd tmt1
libdl.so.2 => /lib/libdl.so.2 (0x4001f000)
libc.so.6 => /lib/libc.so.6 (0x40029000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

Den Jean
to Florian Klaempfl
Florian Klaempfl wrote
I built a new cross snapshot with all those issues fixed:

Big Big Big Thanks.

I can already cross-compile my demo program of

http://users.pandora.be/Jan.Van.hijfte/qtforfpc/qtedemo.html

I updated it (wrong libraryname and some other stuff) and added some screenshots.

Now I am struggling with stuff like

--------------------------------------------------------- No Qt/Embedded server appears to be running
If you want to run this program as a server
add the -qws command-line option
---------------------------------------------------------

Though it should be (I think, not sure) when I am on the Zaurus ?! And when I add -qws as suggested, I get

--------------------------------------------------------- cannot find font definition file /usr/local/qte-embedded/lib/fonts/fontdir is QTDIR set correctly
---------------------------------------------------------

echo $QTDIR reveals /home/QtPalmtop
and there is a /home/QtPalmtop/lib/fontdir as it should be. So I do not know
I'll search further

***********************************************
Thanks again for the great work on the arm compiler. ***********************************************

I will report asap when I get something of Qt/E running on the Zaurus with FPC. (I already tried the C++ example and that works)

kind regards,

Den Jean

Florian Klaempfl
to Den Jean
Den Jean wrote 22 lines
On Friday 05 November 2004 08:57 am, Florian Klaempfl wrote: >I built a new cross snapshot with all those issues fixed: Big Big Big Thanks. I can already cross-compile my demo program of http://users.pandora.be/Jan.Van.hijfte/qtforfpc/qtedemo.html I updated it (wrong libraryname and some other stuff) and added some screenshots. Now I am struggling with stuff like --------------------------------------------------------- No Qt/Embedded server appears to be running If you want to run this program as a server add the -qws command-line option ---------------------------------------------------------

The arm port currently has still some problems, maybe it's simply related to an FPC bug. Try to get FPC daily from cvs.

make crossall CPU_TARGET=arm

and

make crossinstall CPU_TARGET=arm

should build a new fpc/arm for you.

Before I can test it, I've to reinstall my Zaurus, when updating to 3.5.1, the installation got broken :/

Den Jean
to Florian Klaempfl
Florian Klaempfl wrote
Before I can test it, I've to reinstall my Zaurus, when updating to 3.5.1, the installation got broken :/

It is time to reinstall your Zaurus.
I just managed to create a small Qt program with FPC on the Zaurus :-)

Zaurus screenshot:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/ScreenShot02.html get sources on:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/qtedemo.html

The bigger demo does not work yet on ARM, though it does on INTEL,

Intel Framebuffer screenshot:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/ScreenShot01.html

So there are some problems to solve.
I will try to isolate the code that is problematic.

kind regards,

Den Jean

Florian Klaempfl
to Den Jean
Den Jean wrote 8 lines
On Sunday 07 November 2004 04:30 am, Florian Klaempfl wrote: >Before I can test it, I've to reinstall my Zaurus, when updating to >3.5.1, the installation got broken :/ > It is time to reinstall your Zaurus.

Hopefully, I'll get the new (and bigger ;)) SD card today so I can reinstall properly.

Den Jean
to Florian Klaempfl
Florian Klaempfl wrote
>>Before I can test it, I've to reinstall my Zaurus, when updating to >>3.5.1, the installation got broken :/

I have prepared something to test.

I created a small C-program as a reference (that works) and then a FPC program that has a problem (it crashes when compiled for ARM but not when compiled for intel/qvfb)

The program is a minimal Qt program with only one button. We want to connect a pascal procedure to that button. The binding is for pascal so it provides hooks to connect pascal TMethods.

--------------------------------------------------------------------------------------------
// Pascal code that connects a method to the slot clicked()
QButton_clicked_Event(Method):=MyClass.AppQuit;
QButton_hook_hook_clicked(button_hook,Method);
--------------------------------------------------------------------------------------------

It is this code that does not work under arm,
when the Method is called (the button is clicked), the program crashes.

By the way (not related to the problem)
I did not give the button any text, because
for this I need to initialize the binding with
some external pascal code (see bindhelp),
and this is not possible in the simple C program.

To show how the Pascal Method gets called in the binding Here are some extracts of the binding.
The signal clicked() gets connected to a slot of the Qt binding

----------------------------------------------------------------------------------------------
// this is C++ code that implements QButton_hook_hook_clicked(button_hook,Method);
// Method is passed as parameter hook and stored in variable clicked_event
    void hook_clicked(QHook &hook) {
      if ( !clicked_event.func )
        connect(handle, SIGNAL(clicked()), this, SLOT(clicked_hook()));
      clicked_event = hook;
      if ( !hook.func )
        disconnect(handle, SIGNAL(clicked()), this, SLOT(clicked_hook()));
...
...
// clicked_event is defined as this
QHook clicked_event;
...
...
// QHook is defines as this
typedef struct {
  void *func;
  void *data;
} QHook;
typedef QHook QHookH;
...

In the slot handler it calls the pascal method.
---------------------------------------------------------------------------------------------- void clicked_hook() {
if ( clicked_event.func ) {

        typedef void (*func_type)(void *data);
	(*(func_type)clicked_event.func)(clicked_event.data);
      }private slots:

----------------------------------------------------------------------------------------------

I hope this is enough starting information for this bug of the fpc arm crosscompiler. Ask anything you may feel helpfull to solve this.

The codes is here:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/test01.tar.gz

By the way (perhaps related), for the intel/qvfb I need to add unit CMem as the first unit of the uses clause to make any FPC Qt program work.

If I add CMem when compiling for arm, the program does not want to start. it complains with :
------------------------------------------------------------- QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
QSocket::writeBlock: Socket is not open
No Qt/Embedded server appears to be running.
If you want to run this program as a server,
add the -qws command line option.
-------------------------------------------------------------

kind regards,

Den Jean

Den Jean
to Den Jean
Den Jean wrote
it crashes when compiled for ARM

I also debugged it on the zaurus with gdb.

On clicking the button that is attached to AppQuit I get: Program received signal SIGILL, Illegal instruction. $000a0e84 in U_SYSUTILS_UPPERCASETABLE ()

I also checked wether method.func corresponds to @MyClass.AppQuit and method.data to MyClass. So I added this pascal code.

------------------------------------------------------------------------------------------
QButton_clicked_Event(Method):=MyClass.AppQuit;
writeln('@MyClass.AppQuit:',IntToHex(integer(@MyClass.AppQuit),4));
writeln('@Method.code:',IntToHex(integer(Method.code),4));
writeln('MyClass:',IntToHex(integer(MyClass),4));
writeln('@Method.data:',IntToHex(integer(Method.data),4))
------------------------------------------------------------------------------------------

A screenshot for fun of gdb debugging this fpc program on the zaurus is here: http://users.pandora.be/Jan.Van.hijfte/qtforfpc/test01.png

I hope this helps.

kind regards,

Jan

Den Jean
to Den Jean
Den Jean wrote
I also debugged it on the zaurus with gdb.

I debugged somewhat more and this learned me that the record Method is passed by reference instead of by value as it should. With a little hack I managed to force a call by value.

Library extract that shows the function that expects a record by value.
--------------------------------------------------------------------------------------------------------------
   // C definition in library of function that expects a record of type TMethod by value (hook parameter)
   C_EXPORT void QButton_hook_hook_clicked(QButton_hookH handle, QHookH hook);
  // definition of QHookH in library
  typedef struct {
    void *func;
    void *data;
  } QHook;
  typedef QHook QHookH;
--------------------------------------------------------------------------------------------------------------
Here is the Pascal code that passed the record by reference instead of by value
--------------------------------------------------------------------------------------------------------------
  // Pascal definition of external library function
  QHookH = TMethod;
  procedure QButton_hook_hook_clicked(handle: QButton_hookH; hook: QHookH); cdecl;
  procedure QButton_hook_hook_clicked; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked';
  // pascal code that calls the library function and passes the record by reference instead of by value
  QButton_hook_hook_clicked(button_hook,Method);
--------------------------------------------------------------------------------------------------------------
Here is the hack that enables me to force passing by value (the program than works)
--------------------------------------------------------------------------------------------------------------
  procedure QButton_hook_hook_clicked2(handle: QButton_hookH; func: integer; data: integer); cdecl;
  procedure QButton_hook_hook_clicked2; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked';
  // this call works
  QButton_hook_hook_clicked2(button_hook,integer(Method.code),integer(Method.data));
--------------------------------------------------------------------------------------------------------------

I hope this helps in fixing the arm-port. :-)

kind regards,

Jan

Florian Klaempfl
to Den Jean
Den Jean wrote 53 lines
On Sunday 21 November 2004 11:41 pm, Den Jean wrote: >I also debugged it on the zaurus with gdb. > I debugged somewhat more and this learned me that the record Method is passed by reference instead of by value as it should. With a little hack I managed to force a call by value. Library extract that shows the function that expects a record by value. -------------------------------------------------------------------------------------------------------------- // C definition in library of function that expects a record of type TMethod by value (hook parameter) C_EXPORT void QButton_hook_hook_clicked(QButton_hookH handle, QHookH hook); // definition of QHookH in library typedef struct { void *func; void *data; } QHook; typedef QHook QHookH; -------------------------------------------------------------------------------------------------------------- Here is the Pascal code that passed the record by reference instead of by value -------------------------------------------------------------------------------------------------------------- // Pascal definition of external library function QHookH = TMethod; procedure QButton_hook_hook_clicked(handle: QButton_hookH; hook: QHookH); cdecl; procedure QButton_hook_hook_clicked; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked'; // pascal code that calls the library function and passes the record by reference instead of by value QButton_hook_hook_clicked(button_hook,Method); -------------------------------------------------------------------------------------------------------------- Here is the hack that enables me to force passing by value (the program than works) -------------------------------------------------------------------------------------------------------------- procedure QButton_hook_hook_clicked2(handle: QButton_hookH; func: integer; data: integer); cdecl; procedure QButton_hook_hook_clicked2; external QtShareName name QtNamePrefix + 'QButton_hook_hook_clicked'; // this call works QButton_hook_hook_clicked2(button_hook,integer(Method.code),integer(Method.data)); -------------------------------------------------------------------------------------------------------------- I hope this helps in fixing the arm-port. :-)

This is indeed an improper implemntation of the arm abi, I'll fix it asap. BTW: What OS do you run on your Zaurus? I've a lot of trouble with OZ 3.5.1 e.g. with that ridiculous dropbear ssh demon used by OZ 3.5.1

Den Jean
to Florian Klaempfl
Florian Klaempfl wrote
This is indeed an improper implemntation of the arm abi, I'll fix it asap.

Thanks a lot. In the mean time I changed the binding so that it uses LargeInt instead of TMethod. So the big demo program almosts works :-)

---------------------------------------------------------------------------------------------------
QHookH = LargeInt; // was TMethod before
procedure QButton_hook_hook_clicked(handle: QButton_hookH; hook: QHookH); cdecl;
procedure TQButton.Hook_clicked(Proc: QButton_clicked_Event);
begin
  QButton_hook_Hook_clicked(Hooks,LargeInt(TMethod(Proc)));  // Proc gets passed by value :-)
end;//                                               ^^^^^^^^^^^^^^^
---------------------------------------------------------------------------------------------------

I am struggling now with (or having fun with, depending on the view point)

* Trigonometric functions.
So temporarily I am using series like sin x = x- x^3/3! .... Is this related to the fact that there is no Math processor on the Zaurus ? "dmesg" reveals that there is a Netwinder Floating Point Emulator. I haven't looked into the details yet. (which values crash what functions, I use cos/sin and arctan2). I'll do so asap.

* dynamic arrays : TIntArray = array of integer.
On Intel it works fine but on arm not.
Bindhelp.pas provides TIntArray pascal helper functions to the binding that is written in C++

eg. this C-code copies integers from the Qt Int Array to the Pascal dynamic Array of integer

--------------------------------------------------------------------------------------------------- inline void copyQIntsToPInts(const QValueList<int> &qi, PIntArray pi) {

    int len = qi.count();
    int *ints;
    setIntsLength(pi, len); // this is call to a pascal SetIntsLength function
    ints = (int *)getIntsPtr(pi);  // this is a call to a pascal GetIntsPtr function
    for (int i = 0; i < len; i++)
      ints[i] = qi[i]; // here it crashes
  }

----------------------------------------------------------------------------------------------------

    I crashes when it uses the address returned by getintsptr
    GetIntsPtr is provided by bindhelp.pas:
----------------------------------------------------------------------------------------------------
  // Int array helpers
  function GetIntsPtr(const PA: TIntArray): Pointer; cdecl; export;
  begin
    Result := @PA[0];
  end;
----------------------------------------------------------------------------------------------------

It works on intel and not on arm.
But when I change the definition of GetIntsPtr to:

----------------------------------------------------------------------------------------------------
  function GetIntsPtr(var PA: TIntArray): Pointer; cdecl; export;
  begin
    Result := @PA[0];
  end;
----------------------------------------------------------------------------------------------------

Then it works on the arm to. (changed const to var !)

By the way the definition of the pascal library function in the C++ library is:
----------------------------------------------------------------------------------------------------
  typedef void *PIntArray;
  typedef void *(*GetIntsPtr)(PIntArray pi);
  extern GetIntsPtr getIntsPtr;
----------------------------------------------------------------------------------------------------

* I am using the last arm snapshot you provided because the current cvs version does not compile

BTW: What OS do you run on your Zaurus? I've a lot of trouble with OZ 3.5.1 e.g. with that ridiculous dropbear ssh demon used by OZ 3.5.1

I have a Zaurus SL6000. As it is rather new, an upgrade was not a priority yet. I haven't seen update roms for the SL6000 either.
The SL6000 has a libqte.so.2.3.2 and a libqpe.so.1.5.0

kind regards,

Jan

Florian Klaempfl
to Den Jean
Den Jean wrote 28 lines
On Tuesday 23 November 2004 11:13 am, Florian Klaempfl wrote: * dynamic arrays : TIntArray = array of integer. On Intel it works fine but on arm not. Bindhelp.pas provides TIntArray pascal helper functions to the binding that is written in C++ eg. this C-code copies integers from the Qt Int Array to the Pascal dynamic Array of integer --------------------------------------------------------------------------------------------------- inline void copyQIntsToPInts(const QValueList<int> &qi, PIntArray pi) { int len = qi.count(); int *ints; setIntsLength(pi, len); // this is call to a pascal SetIntsLength function ints = (int *)getIntsPtr(pi); // this is a call to a pascal GetIntsPtr function for (int i = 0; i < len; i++) ints[i] = qi[i]; // here it crashes } ---------------------------------------------------------------------------------------------------- I crashes when it uses the address returned by getintsptr GetIntsPtr is provided by bindhelp.pas: ---------------------------------------------------------------------------------------------------- // Int array helpers function GetIntsPtr(const PA: TIntArray): Pointer; cdecl; export; begin Result := @PA[0]; end;^

I fear the snapshot was created before a lot of dyn. array stuff was fixed.

Show quoted text 22 lines
---------------------------------------------------------------------------------------------------- It works on intel and not on arm. But when I change the definition of GetIntsPtr to: ---------------------------------------------------------------------------------------------------- function GetIntsPtr(var PA: TIntArray): Pointer; cdecl; export; begin Result := @PA[0]; end; ---------------------------------------------------------------------------------------------------- Then it works on the arm to. (changed const to var !) By the way the definition of the pascal library function in the C++ library is: ---------------------------------------------------------------------------------------------------- typedef void *PIntArray; typedef void *(*GetIntsPtr)(PIntArray pi); extern GetIntsPtr getIntsPtr; ---------------------------------------------------------------------------------------------------- * I am using the last arm snapshot you provided because the current cvs version does not compile

I know, but I've to get my arm working first :(

Show quoted text 11 lines
>BTW: What OS do you run on your Zaurus? I've a lot of trouble with >OZ 3.5.1 e.g. with that ridiculous dropbear ssh demon used by OZ 3.5.1 I have a Zaurus SL6000. As it is rather new, an upgrade was not a priority yet. I haven't seen update roms for the SL6000 either. The SL6000 has a libqte.so.2.3.2 and a libqpe.so.1.5.0
Den Jean
to Florian Klaempfl
Florian Klaempfl wrote
I know, but I've to get my arm working first :(

Another incentive to get your zaurus up and running again. The demo program now works on the Zaurus :-)

The updated now uses LargeInt instead of TMethod.
Some temporary trigonometric functions (cos/sin/arctan) have been added to demo program for the arm. I still have some problems with interfaces
--> lifetime problems with _addref and
--> plain crashes for what seems to be valid code. (I avoided these calls for the moment) But I will try to isolate these problems into a very small program.

In the mean time enjoy these animated screenshots of the demo program running on the Zaurus. http://users.pandora.be/Jan.Van.hijfte/qtforfpc/ScreenShot03.html

for sources look on http://users.pandora.be/Jan.Van.hijfte/qtforfpc/qtedemo.html

kind regards,

Den Jean