Recent

Author Topic: LCL for arm (STM32MP1)  (Read 3477 times)

Escain

  • New member
  • *
  • Posts: 9
LCL for arm (STM32MP1)
« on: January 31, 2023, 11:02:24 am »
Hi!

This is my first message on this forum, so a quick intro: I'am Adrian, software engineer currently working on CNC systems. I am used to C++ language but got recently to work with FreePascal, so I am a total newbie with Lazarus and FPC. Nice to meet you all :-)


Goal:
I am trying to port a project (some 1/2M lines) from Delphi-11 to an ARM Stm32MP1, if you are not familiar with this chip, you may just imagine some Raspberry Pi.
I managed to create simple (working) examples with both Lazarus+LAMW and Firemonkey, but their API is quite different than Delphi-11, consequently, I am trying to make some simple Linux+LCL example to work on that target platform.

Environment:

Host:
+ Windows 10 or Linux (Debian Bullseye)
+ amd64
Target:
+ Android or Linux (custom Yocto distro)
+ Wayland, with Qt5 or GTK3
+ ARM Cortex7

What I achieved so far:
I successfully installed Lazarus and the ARM tool-chain through "FpcUpdDeluxe".

The problem:
The problem that blocks me since few days is that the Linux (created with Yocto) works with Wayland, not X11. And all the LCL framework seems to work with X11, not Wayland. The link stage fails with -lX11 not found

[[See image]]

Note: I copied most .so from the target linux, because installed with FPCUpDeluxe were not of a compatible version. This is probably not 100% correct.

I tried to create a new Linux with X11, but that capability was dropped years ago. Until now, I did not managed to build that image.

Searching how to have LCL working with Wayland was not a success neither.
Could I kindly ask you for guidance on how to have LCL working with Wayland for ARM target?

TLTR;

I am looking for help to make LCL working on a wayland linux distro on ARM architecture.


af0815

  • Hero Member
  • *****
  • Posts: 1284
Re: LCL for arm (STM32MP1)
« Reply #1 on: January 31, 2023, 11:27:21 am »
First off all, have you a simple "Hello world" without the LCL running on the Target ? This is a startingpoint to see the compiler itself and the fcl works for the target.

Edit: Alexey-T seem to have some issue with Wayland and XWayland too.
https://github.com/Alexey-T/CudaText/issues/3592 eventaully he have more experience.

 
« Last Edit: January 31, 2023, 11:34:09 am by af0815 »
regards
Andreas

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: LCL for arm (STM32MP1)
« Reply #2 on: January 31, 2023, 12:03:23 pm »
You might be better to Target gtk2.  Sadly, GTK3 is not really ready yet. Qt5 would be heaps better than GTK3 but it has more problems with Wayland than GTK2.

While most current Linux distros now handle Qt5 and Wayland reasonably well (using a xwayland) my guess is very little work will have gone into doing so on an Arm platform and the things done are quite low level.

But if you are committed to not using gtk2 (because of its age), then qt5 it might have to be. As a extra, Qt5 is only a quarter the size of gtk2. Make sure you have xwayland, maybe xcb too.

Davo

Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Escain

  • New member
  • *
  • Posts: 9
Re: LCL for arm (STM32MP1)
« Reply #3 on: January 31, 2023, 12:27:46 pm »
First off all, have you a simple "Hello world" without the LCL running on the Target ? This is a starting point to see the compiler itself and the fcl works for the target.

Yes, I did a "Hello world" program, 'scp' it to the target and it works :-)
So the tool-chain seems almost working. (Almost because LCL is not working)

But if you are committed to not using gtk2 (because of its age), then qt5 it might have to be. As a extra, Qt5 is only a quarter the size of gtk2. Make sure you have xwayland, maybe xcb too.

I have some preference for Qt5 (because I am familiar with it), but my first goal is to have something working. GTK2 can do it for now, then, I can dig further for Qt5 if necessary. So, if it's easier, I will try it first.

So any hint is welcome.
« Last Edit: January 31, 2023, 02:30:45 pm by Escain »

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: LCL for arm (STM32MP1)
« Reply #4 on: February 01, 2023, 01:21:14 am »
The beauty of LCL is that you can build something in one particular widget set and with often nothing more that a compile switch switch to another.

So, develop in what ever seems well supported on the platform at the time (and I suggest gtk2 because its been around longest) and switch to another as its support matures.

>I have some preference for Qt5 (because I am familiar with it), ...

Depending on what you are doing (and you are plainly tackling a BIG project), you may find that familiarity of little relevance. LCL is that good at what it sets out to do ! There are, of course, corner cases ....

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Escain

  • New member
  • *
  • Posts: 9
Re: LCL for arm (STM32MP1)
« Reply #5 on: February 01, 2023, 10:07:51 am »
When switching to GTK2, I get mostly the same issue:

Code: Pascal  [Select][+][-]
  1. Compile package LCL 2.2.4: Success, Hints: 2
  2. Hint: Start of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfg
  3. Hint: End of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfg
  4. Verbose: Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2023/01/19] for arm
  5. Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
  6. Verbose: Target OS: Linux for ARMHF
  7. Verbose: Compiling lcl.pas
  8. Verbose: 21 lines compiled, 8.1 sec
  9. Verbose: 2 hint(s) issued
  10. Compile Project, OS: linux, CPU: arm, Target: project1: Exit code 1, Errors: 1, Hints: 2
  11. Hint: Start of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfg
  12. Hint: End of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfg
  13. Verbose: Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2023/01/19] for arm
  14. Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
  15. Verbose: Target OS: Linux for ARMHF
  16. Verbose: Compiling project1.lpr
  17. Verbose: Compiling unit1.pas
  18. Verbose: Compiling resource C:\fpcupdelux32\projects\lib\arm-linux\project1.or
  19. Verbose: Linking C:\fpcupdelux32\projects\project1
  20. Debug: C:\fpcupdelux32\cross\bin\arm-linux\arm-linux-gnueabihf-ld.exe: cannot find -lgdk-x11-2.0
  21. Debug: C:\fpcupdelux32\cross\bin\arm-linux\arm-linux-gnueabihf-ld.exe: cannot find -lX11
  22. project1.lpr(24,1) Error: Error while linking
  23. project1.lpr(24,1) Verbose: There were 1 errors compiling module, stopping
  24. Verbose: Compilation aborted
  25. Verbose: C:\fpcupdelux32\fpc\bin\i386-win32\ppcrossarm.exe returned an error exitcode

Note: X11 is not available.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1738
Re: LCL for arm (STM32MP1)
« Reply #6 on: February 01, 2023, 11:16:52 am »
I guess you need to switch towards QT[5/6]. And drop GTK.
QT should work nicely, as it does on Haiku (also a distro without GTK support).

Escain

  • New member
  • *
  • Posts: 9
Re: LCL for arm (STM32MP1)
« Reply #7 on: February 01, 2023, 11:44:04 am »
Quote
I guess you need to switch towards QT[5/6]. And drop GTK.
QT should work nicely, as it does on Haiku (also a distro without GTK support).

I tried all possibilities, they all relay on X11.

I expect either some configuration for Qt/GTK to use wayland, or some procedure to rebuild LCL using ARM+Linux+Wayland

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: LCL for arm (STM32MP1)
« Reply #8 on: February 01, 2023, 11:47:04 am »
What about just enabling x11 support in your Yocto image?

Escain

  • New member
  • *
  • Posts: 9
Re: LCL for arm (STM32MP1)
« Reply #9 on: February 01, 2023, 12:12:29 pm »
Quote
What about just enabling x11 support in your Yocto image?

I am working on that currently: X11 has been dropped some 2 years ago by STM, so I am facing libraries incompatibilities. I found few forks attempting to configure Yocto image for it, none has worked so far. I am still on it trying to fix library incompatibilities and configuration issues, but I also wanted to explore LCL alternatives.

Also, considering that wayland is increasingly being the de-facto standard, I see X11 only as a short term solution.

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: LCL for arm (STM32MP1)
« Reply #10 on: February 01, 2023, 02:01:05 pm »
When switching to GTK2, I get mostly the same issue:
...
Note: X11 is not available.
Did you install libgtk2.0-dev? I recently struggled to get Lazarus working on a Raspberry Pi OS (Buster I think), but after installing one key library (I think it was gdk_pixbuf) the rest of the dependencies were also pulled in.

Also check this section on the wiki regarding fixing of potential version issues.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: LCL for arm (STM32MP1)
« Reply #11 on: February 01, 2023, 06:27:22 pm »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: LCL for arm (STM32MP1)
« Reply #12 on: February 01, 2023, 07:03:56 pm »
Also, considering that wayland is increasingly being the de-facto standard, I see X11 only as a short term solution.

If you want  absolutely Wayland, you should take a look at  Andrew's code: https://github.com/andrewd207/fpc-wayland
( But I am not sure Wayland will be the standard soon and it will need XWayland for long time (maybe forever) ).
« Last Edit: February 01, 2023, 07:06:22 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: LCL for arm (STM32MP1)
« Reply #13 on: February 02, 2023, 12:25:40 am »
Code: Pascal  [Select][+][-]
  1. Debug: C:\fpcupdelux32\cross\bin\arm-linux\arm-linux-gnueabihf-ld.exe: cannot find -lgdk-x11-2.0
  2. Debug: C:\fpcupdelux32\cross\bin\arm-linux\arm-linux-gnueabihf-ld.exe: cannot find -lX11

You need to install at least the two dev libraries mentioned above.  Get those on and it might expose further needs but thats a start. Note, while the complaint is about not finding eg gdk-x11-2.0 its really not finding
things installed by libgtk2.0-dev and libx11-dev.

And libgtk2.0-dev is not installed automatically when gtk2 itself is, the -dev packages are only needed during the linking stage, not needed at run time. See https://wiki.freepascal.org/Installing_Lazarus_on_Linux#Build_Lazarus_from_Source

Oh, ccrause already said that, sorry ! Its definitly your problem anyway.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Escain

  • New member
  • *
  • Posts: 9
Re: LCL for arm (STM32MP1)
« Reply #14 on: February 02, 2023, 04:48:12 pm »
I managed to create an image with X11, so it's "solved" in that I made the other side compatible with LCL, not LCL compatible with wayland.

Quote
Did you install libgtk2.0-dev?
Unfortunately, I have no access to any "dev" library, the device is too low in specs to build anything, and gtk2 is not supported anymore (I have choice between GTK3 and GTK4). I could probably find a way to cross-compile it.

Quote
But I am not sure Wayland will be the standard soon and it will need XWayland for long time (maybe forever)
Well, openst-linux already works without XWayland. This is not any hypothetical future.

Quote
Sadly, GTK3 is not really ready yet.
Did you meant that LCL for GTK3 is not really ready yet? GTK3 is 12 years old, GTK4 is also several years old now.


Thank you for all your help, if any is going through this page, I fixed the issue with:

+ Using OpenSt-Linux from official STM github repo, using the latest "kirkstone"
+ Copied weston recipe and switched most of the wayland to X11 / XWayland.
+ Fixed Gallium & libxshmfence following https://community.st.com/s/question/0D53W00001nB3AiSAK/error-when-trying-to-combine-x11-with-weston-in-ecosystem-release-v400
+ Copied all required libs into the FPC cross folder for building my app with LCL.

 

TinyPortal © 2005-2018