termux-user-repository / tur

A place for all types of Termux packages.
Other
410 stars 78 forks source link

FreePascal + Lazarus It almost works but fails to start.. #1139

Closed PTz0uAH closed 1 week ago

PTz0uAH commented 1 month ago

Hoi Termux devs/fans..

Hope to get some help overhere as it was "Not related to X server functionality" according to the Termux-x11 moderator..

I was very happy I got FreePascal 3.3.1 from trunk working and wanted also to build Lazarus for Termux-X11..

Hence I needed to adapt the FPC/LAZ source code for Termux usage and finally completed the Lazarus X11 GTK2 build..

As I am very eager to get Lazarus to work on XFCE4 It seems I missed something and got stuck testing it..

Any help is welcome to get it working without proot/croot so, when it all works out, we might even have a distributable deb for the pascal-dev-on-termux-community..

with kind regards.. Peter

Screenshot_20240810-113531 Screenshot_20240810-121812 Screenshot_20240810-123558

PTz0uAH commented 1 month ago

Some additional info so it might help thinking of a solution..

On WSL I had to execute this script to get it all working so I "just" need to install the Termux (linux-android) equivalents which seems a lot of puzzling.. albeit someone encountered problems alike.. but I guess it will take some effort to sort it out..

#!/bin/sh apt install gir1.2-atk-1.0 \ gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-gtk-2.0 \ gir1.2-harfbuzz-0.0 gir1.2-pango-1.0 gtk-update-icon-cache \ hicolor-icon-theme icu-devtools liba52-0.7.4 liba52-0.7.4-dev libaom-dev \ libasound2-dev libasyncns0 libatk1.0-0 libatk1.0-dev libavif-dev \ libblkid-dev libbrotli-dev libcaca-dev libcaca0 libcairo-gobject2 \ libcairo-script-interpreter2 libcairo2 libcairo2-dev libcdt5 libcgraph6 \ libdatrie-dev libdatrie1 libdav1d-dev libde265-dev libdecor-0-0 \ libdecor-0-plugin-1-cairo libdeflate-dev libdrm-amdgpu1 libdrm-common \ libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libegl-dev libegl-mesa0 \ libegl1 libffi-dev libflac-dev libfluidsynth3 libfontconfig-dev libforms-dev \ libforms2 libfreetype-dev libfribidi-dev libgail-common libgail18 libgbm1 \ libgd-dev libgdk-pixbuf-2.0-0 libgdk-pixbuf-2.0-dev libgdk-pixbuf2.0-bin \ libgdk-pixbuf2.0-common libgirepository-1.0-1 libgl-dev libgl1 \ libgl1-mesa-dev libgl1-mesa-dri libglapi-mesa libgles-dev libgles1 libgles2 \ libglib2.0-bin libglib2.0-dev libglib2.0-dev-bin libglu1-mesa \ libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libglvnd0 libglx-dev \ libglx-mesa0 libglx0 libgraphite2-dev libgraphviz-dev libgtk2.0-0 \ libgtk2.0-bin libgtk2.0-common libgtk2.0-dev libgts-0.7-5 libgts-bin libgvc6 \ libgvc6-plugins-gtk libgvpr2 libharfbuzz-dev libharfbuzz-gobject0 \ libharfbuzz-icu0 libharfbuzz-subset0 libheif-dev libice-dev libice6 \ libicu-dev libidn12 libinstpatch-1.0-2 libjack-jackd2-0 libjbig-dev \ libjpeg-dev libjpeg62-turbo-dev liblab-gamut1 liblerc-dev liblhasa0 \ libllvm15 liblzma-dev liblzo2-2 libmad0 libmad0-dev libmikmod-dev libmikmod3 \ libmodplug-dev libmodplug1 libmount-dev libogg-dev libopenal-data libopenal1 \ libopengl-dev libopengl0 libpango-1.0-0 libpango1.0-dev libpangocairo-1.0-0 \ libpangoft2-1.0-0 libpangoxft-1.0-0 libpathplan4 libpciaccess0 libpcre2-16-0 \ libpcre2-32-0 libpcre2-dev libpcre2-posix3 libpixman-1-0 libpixman-1-dev \ libpkgconf3 libpng-dev libpng-tools libproxy-tools libproxy1v5 \ libpthread-stubs0-dev libpulse-dev libpulse-mainloop-glib0 libpulse0 \ librsvg2-2 librsvg2-common libsamplerate0 libsdl-mixer1.2 \ libsdl-mixer1.2-dev libsdl1.2-dev libsdl1.2debian libsdl2-2.0-0 \ libselinux1-dev libsensors-config libsensors5 libsepol-dev libslang2-dev \ libsm-dev libsm6 libsndio7.0 libthai-data libthai-dev libthai0 libtiff-dev \ libtiffxx6 libvlc-bin libvlc-dev libvlc5 libvlccore9 libvorbis-dev \ libvpx-dev libvpx7 libwayland-client0 libwayland-cursor0 libwayland-egl1 \ libwayland-server0 libwebp-dev libwebpdemux2 libwebpmux3 libx11-dev \ libx11-xcb1 libx265-dev libxau-dev libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 \ libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-render0-dev libxcb-shm0 \ libxcb-shm0-dev libxcb-sync1 libxcb-xfixes0 libxcb1-dev libxcomposite-dev \ libxcomposite1 libxcursor-dev libxcursor1 libxdamage-dev libxdamage1 \ libxdmcp-dev libxdot4 libxext-dev libxfixes-dev libxfixes3 libxft-dev \ libxft2 libxi-dev libxi6 libxinerama-dev libxinerama1 libxkbcommon0 \ libxml2-utils libxpm-dev libxrandr-dev libxrandr2 libxrender-dev libxrender1 \ libxshmfence1 libxss1 libxxf86dga-dev libxxf86dga1 libxxf86vm-dev \ libxxf86vm1 libz3-4 libzstd-dev pango1.0-tools pkg-config pkgconf \ pkgconf-bin timgm6mb-soundfont uuid-dev x11-common x11proto-core-dev \ x11proto-dev xkb-data xorg-sgml-doctools xtrans-dev

licy183 commented 1 month ago

It seems that the RUNPATH of startlazarus is not correctly set. Try readelf -d startlazarus and see if it is set correctly. It should be set to /data/data/com.termux/files/usr/lib.

PTz0uAH commented 1 month ago

@licy183 thanks for your suggestion..

readelf -d startlazarus is not showing RUNPATH probably because I use not CMAKE but a pure GCC10 installation..

Then I thought about the fact I did not even test gtk2 with pure FPC so I tested the FreePascal/gtk2 examples first..

The compiled example did not run and gave a similar error so that was a starting point to find a solution..

What I've learned today was the usage of LD_LIBRARY_PATH as a workaround for "wrong paths" compiled into the binary.. although that method was strongly adviced to be used as a last resort.. if nothing else worked.. (the developer should change the bad paths in code)..

Then I created a wrapper which sets the LD_LIBRARY_PATH and voilá things started to work.. and for the first time I had confirmation that gtk2 is working inside XFCE4 non-proot/non-croot.. pure Termux..

That brought hope.. since Lazarus is nothing but a bunch of FPC compiled binaries..

Here a screenshot of the achievement..

Screenshot_20240811-124136

To be continued..

PTz0uAH commented 1 month ago

Status & Progress.. "Well.. does it work? Of course! (not)"

Finally had the courage to perform the run startlazarus expecting serious trouble and this is what I got..

Screenshot_20240812-221947

That seems normal behaviour since lazarus needs also a bunch of config files and some fundamental paths are incorrect/missing.. it is only logical the IDE does not show.. but we have no errors..

Using the "run" command really did some "magic" so it seems..

To be continued..

PTz0uAH commented 1 month ago

Status & Progress "What about FPC? Boldly go where no-one has gone before?"

FPC is fundamental for pascal-dev fans to build anything one wants and since its a lot of pioneering the outcome is uncertain..

Therefore I defined a goal.. to keep myself motivated..

GOAL: I want to develop on-device (pure Termux/XFCE) with FPC/(Lazarus) programs/games with the great "Castle Game Engine".. (& also cross build with FPC classic-amiga software for usage with the UAE4ARM/vAmigaWeb/etc. Amiga-emulators) & test/debug the result on the XFCE desktop to shorten the dev-cycle & finally build the project into a signed debug/release APK.. & install it like a regular APK on the device.. in that way we have real hardware-acceleration at hand even on cheap yet capable devices.. & therefore be able to start the app from terminal.. the "Oldskool" way..

FALLBACK: if it shouldn't work out we can always fallback to the "proot" option.. with i.e. a debian install.. but I hope to keep it pure Termux/XFCE.. saves a zillion cpucycles.. :)

What I have learned today is that Lazarus gtk2 needs a fully functional FPC so I have to adapt/build/test all the (for aarch64/android build target not yet available) fpc-packages for Termux complience/compatibility..

To showcase what already runs I recorded on-device a short video about pure FPC OpenGL examples running fine after being "Termuxified" if you know what I mean..

So please enjoy another achievement..

https://github.com/user-attachments/assets/dcdd227a-13eb-4bab-975c-5de3f43c8e93

To be continued..

IntinteDAO commented 4 weeks ago

I count on you to succeed. I wanted to move FPC myself, but I'm too weak :P

And a little application requires this compiler

PTz0uAH commented 3 weeks ago

@IntinteDAO thanks for the encouragement..

It is already possible to use FPC on Termux Android with official builds provided by https://www.freepascal.org/download.html

Though it needs fpc.cfg configured properly and that is the first hurdle to overcome if you really want to learn to work with FreePascal..

It will take some time before a stable and full 3.2.2 release is available as termux package.. but I am working on it..

I still have to learn a lot about Termux as it is the 22th day since first Termux installation.. but with some Linux experience it was not super difficult to comprehend..

PTz0uAH commented 1 week ago

Status & Progress "FreePascal back to basics & just one more package to go"

A stable release of FPC v3.2.2 can only be build by a stable compiler..

FPC from trunk (3.3.1) has always been categorized as unstable even though it might work well.. you get the latest additions at the risk of buggy behaviour..

"Normal" users prefer a stable release which is more robust in production environments..

Creating a full termux distri of FPC v3.2.2 ARM went reasonably well.. using the incomplete FPC v3.2.2 ARM distri by freepascal.org as "bootstrap compiler"..

progress_arm progress_aarch64

One more achievement to go.. what I have to do is using the freepascal.org distri FPC v3.20 AARCH64 to build a FPC v3.2.2 AARCH64 stable distri.. the methods I use worked to create FPC v3.3.1 from trunk so I think it will take another week or so to get it done..

What I have learned last weeks is creating a distri and deb and setting up an experimental repo for my "fpc4termux" challenge..

Now if we can also manage to build the CGE build-tool with FPC we are going to have a full blown game engine at our disposal but I am still strugling with a lot of linker errors.. build_log.txt

ergo: I guess we can close this issue since all the eyecandy was produced with fpc v3.3.1 from trunk and that will never become a deb-file for mainstream usage.. that learning curve is not for the fainthearted so let's focus on the stable release v3.2.2.

@licy183 you or any termux fpc devs are welcome to test my experimental non-signed stuff .. and maybe report bugs or anomalies via my "termuxified issues" repo.. I know it's not perfect but I am just a couple of months into Termux.. and I think with the right maintainer-scripts you'll get some nice packages for TUR.. or perhaps even mainstream Termux-(X11) packages..

with kind regards,

PTz()uAH