LCL for arm (STM32MP1) lazarus / 1-Linux ---------------------------------------------------------------------- Escain · 2023-01-31 10:02 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 · 2023-01-31 10:27 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. ---------------------------------------------------------------------- dbannon · 2023-01-31 11:03 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 ---------------------------------------------------------------------- Escain · 2023-01-31 11:27 Quote from: af0815 on January 31, 2023, 11:27:21 amFirst 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) Quote from: dbannon on January 31, 2023, 12:03:23 pmBut 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. ---------------------------------------------------------------------- dbannon · 2023-02-01 00:21 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 ---------------------------------------------------------------------- Escain · 2023-02-01 09:07 When switching to GTK2, I get mostly the same issue: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Compile package LCL 2.2.4: Success, Hints: 2Hint: Start of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfgHint: End of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfgVerbose: Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2023/01/19] for armVerbose: Copyright (c) 1993-2021 by Florian Klaempfl and othersVerbose: Target OS: Linux for ARMHFVerbose: Compiling lcl.pasVerbose: 21 lines compiled, 8.1 secVerbose: 2 hint(s) issuedCompile Project, OS: linux, CPU: arm, Target: project1: Exit code 1, Errors: 1, Hints: 2Hint: Start of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfgHint: End of reading config file C:\fpcupdelux32\fpc\bin\i386-win32\fpc.cfgVerbose: Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2023/01/19] for armVerbose: Copyright (c) 1993-2021 by Florian Klaempfl and othersVerbose: Target OS: Linux for ARMHFVerbose: Compiling project1.lprVerbose: Compiling unit1.pasVerbose: Compiling resource C:\fpcupdelux32\projects\lib\arm-linux\project1.orVerbose: Linking C:\fpcupdelux32\projects\project1Debug: C:\fpcupdelux32\cross\bin\arm- linux\arm-linux-gnueabihf-ld.exe: cannot find -lgdk-x11-2.0Debug: C:\fpcupdelux32\cross\bin\arm-linux\arm-linux-gnueabihf-ld.exe: cannot find -lX11project1.lpr(24,1) Error: Error while linkingproject1.lpr(24,1) Verbose: There were 1 errors compiling module, stoppingVerbose: Compilation abortedVerbose: C:\fpcupdelux32\fpc\bin\i386-win32\ppcrossarm.exe returned an error exitcode Note: X11 is not available. ---------------------------------------------------------------------- DonAlfredo · 2023-02-01 10:16 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 · 2023-02-01 10:44 QuoteI 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 · 2023-02-01 10:47 What about just enabling x11 support in your Yocto image? ---------------------------------------------------------------------- Escain · 2023-02-01 11:12 QuoteWhat 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 · 2023-02-01 13:01 Quote from: Escain on February 01, 2023, 10:07:51 amWhen 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 · 2023-02-01 17:27 Did you see https://wiki.lazarus.freepascal.org/Qt5_Interface#Systems_ using_Wayland ? Read whole page if you didn't. ---------------------------------------------------------------------- Fred vS · 2023-02-01 18:03 Quote from: Escain on February 01, 2023, 12:12:29 pmAlso, 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) ). ---------------------------------------------------------------------- dbannon · 2023-02-01 23:25 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Debug: C:\fpcupdelux32\cross\bin\arm-linux\arm-linux-gnueabihf-ld.exe: cannot find -lgdk-x11-2.0Debug: 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_Lin ux#Build_Lazarus_from_Source Oh, ccrause already said that, sorry ! Its definitly your problem anyway. Davo ---------------------------------------------------------------------- Escain · 2023-02-02 15:48 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. QuoteDid 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. QuoteBut 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. QuoteSadly, 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. ---------------------------------------------------------------------- DonAlfredo · 2023-02-02 15:59 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. ---------------------------------------------------------------------- Fred vS · 2023-02-02 17:47 Quote from: Escain on February 02, 2023, 04:48:12 pmQuoteBut 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. ---------------------------------------------------------------------- Thaddy · 2023-02-02 18:00 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. ---------------------------------------------------------------------- Fred vS · 2023-02-02 18:09 Quote from: Thaddy on February 02, 2023, 07:00:24 pmLCL (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. ---------------------------------------------------------------------- Thaddy · 2023-02-02 18:29 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. ---------------------------------------------------------------------- Fred vS · 2023-02-02 18:53 Quote from: Thaddy on February 02, 2023, 07:29:31 pmFred, 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 ---------------------------------------------------------------------- Escain · 2023-02-08 09:50 Quote from: DonAlfredo on February 02, 2023, 04:59:47 pmThat 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. ---------------------------------------------------------------------- BasePointer · 2023-02-22 13:50 My topic previously created may help you: https://forum.lazarus.freepa scal.org/index.php/topic,57876.msg430794.html#msg430794