Lazarus

Installation => Linux => Topic started by: Escain on January 31, 2023, 11:02:24 am

Title: LCL for arm (STM32MP1)
Post by: Escain 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.

Title: Re: LCL for arm (STM32MP1)
Post by: af0815 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.

 
Title: Re: LCL for arm (STM32MP1)
Post by: dbannon 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

Title: Re: LCL for arm (STM32MP1)
Post by: Escain 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.
Title: Re: LCL for arm (STM32MP1)
Post by: dbannon 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
Title: Re: LCL for arm (STM32MP1)
Post by: Escain 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.
Title: Re: LCL for arm (STM32MP1)
Post by: DonAlfredo 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).
Title: Re: LCL for arm (STM32MP1)
Post by: Escain 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
Title: Re: LCL for arm (STM32MP1)
Post by: Laksen on February 01, 2023, 11:47:04 am
What about just enabling x11 support in your Yocto image?
Title: Re: LCL for arm (STM32MP1)
Post by: Escain 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.
Title: Re: LCL for arm (STM32MP1)
Post by: ccrause 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 (https://wiki.lazarus.freepascal.org/GTK2_Interface#Quick_start_guide_for_Linux.2C_FreeBSD.2C_etc)? 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 (https://wiki.lazarus.freepascal.org/GTK2_Interface#Raspberry_Pi_OS) on the wiki regarding fixing of potential version issues.
Title: Re: LCL for arm (STM32MP1)
Post by: avra on February 01, 2023, 06:27:22 pm
Did you see https://wiki.lazarus.freepascal.org/Qt5_Interface#Systems_using_Wayland ? Read whole page if you didn't.
Title: Re: LCL for arm (STM32MP1)
Post by: Fred vS 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) ).
Title: Re: LCL for arm (STM32MP1)
Post by: dbannon 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
Title: Re: LCL for arm (STM32MP1)
Post by: Escain 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.
Title: Re: LCL for arm (STM32MP1)
Post by: DonAlfredo on February 02, 2023, 04:59:47 pm
That is good news.
If you are willing, would you be able to share libs and bins with me to include them into fpcupdeluxe ?
Thanks.
Title: Re: LCL for arm (STM32MP1)
Post by: Fred vS on February 02, 2023, 06:47:00 pm
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.

Yes, Ubuntu-Wayland can also work without XWayland but lot of applications, like Firefox, Google Earth and many others do not work well with their Wayland version and recommend to use the X11+XWayland version on a Wayland system.

But I will be very happy to have fpc-wayland fully working, with demos, for LCL, MSEgui and fpGUI widgetsets.
Title: Re: LCL for arm (STM32MP1)
Post by: Thaddy on February 02, 2023, 07:00:24 pm
LCL (gtk 2 tested) simply works with Wayland. Don't know about the exotics. Platform Debian/ Raspberry Pi OS. Quick test was only 32 bit. Not AArch64. But I will test that too.
Title: Re: LCL for arm (STM32MP1)
Post by: Fred vS on February 02, 2023, 07:09:44 pm
LCL (gtk 2 tested) simply works with Wayland. Don't know about the exotics. Platform Debian/ Raspberry Pi OS.

Hum, if I may, GTK2 has no Wayland feature, so your application should be X11 and Wayland uses XWayland to run it.
By the way, XWayland team does a excellent and no-stop work (much more activity than for Wayland project that seems on pause).
They also decided to add a "extra Xlib" library with all the features that Wayland has (but not X11), so the X11 developer can add Wayland-only-features if the application is running on a XWayland system.
Title: !!
Post by: Thaddy on February 02, 2023, 07:29:31 pm
Fred, sorry, but that is nonsense. Wayland supports GTK2 - btw has nothing to do with it, nothing and I can prove that at least for for the Raspbian implementation.
Title: Re: !!
Post by: Fred vS on February 02, 2023, 07:53:46 pm
Fred, sorry, but that is nonsense. Wayland supports GTK2 - btw has nothing to do with it, nothing and I can prove that at least for for the Raspbian implementation.

GTK2 is a widgetset, (like MSEgui  ;) ) that uses a graphic window server, like X11 in some Unix distro, for rendering.
Afaik, GTK2 cannot use Wayland graphic compositor and so, thanks to XWayland project, mainly all applications using X11 can run with the XWayland-kind-of-X11-emulator installed on some Wayland distros.

So, ( I did not check ) it is highly possible that Raspbian-Wayland distro has XWayland installed.
[EDIT] Yes, htere is one Rpi OS-Wayland version but experimental : https://www.phoronix.com/news/Raspberry-Pi-OS-Wayland
Title: Re: LCL for arm (STM32MP1)
Post by: Escain on February 08, 2023, 10:50:08 am
That is good news.
If you are willing, would you be able to share libs and bins with me to include them into fpcupdeluxe ?
Thanks.
@DonAlfredo

I think adding the libs as binary could be problematic right? (thinking about different versions issues/incompatibilities).

I can either give you the exact build procedure (quite costly in CPU / time)
or the libs/bins if you give me the exact list them that you would need: I copied them as they were needed, so the list is probably not exhaustive. Copying all the .so of the OS is probably an overkill. Let me know and I would share them.

To Others:
Note: It might be that Gtk2 or even Qt5 works fine for wayland and LCL. My problem has some additional variables: ARM cross-compilation.
Title: Re: LCL for arm (STM32MP1)
Post by: BasePointer on February 22, 2023, 02:50:30 pm
My topic previously created may help you: https://forum.lazarus.freepascal.org/index.php/topic,57876.msg430794.html#msg430794
TinyPortal © 2005-2018