Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PTz0uAH opened this issue Aug 10, 2024 · 14 comments
Open

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

PTz0uAH opened this issue Aug 10, 2024 · 14 comments

Comments

@PTz0uAH
Copy link

PTz0uAH commented Aug 10, 2024

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
Copy link
Author

PTz0uAH commented Aug 10, 2024

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
Copy link
Collaborator

licy183 commented Aug 11, 2024

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
Copy link
Author

PTz0uAH commented Aug 11, 2024

@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
Copy link
Author

PTz0uAH commented Aug 12, 2024

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
Copy link
Author

PTz0uAH commented Aug 12, 2024

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..

vlc-record-2024-08-12-22h29m50s-screen-20240812-132627-small.mp4

To be continued..

@IntinteDAO
Copy link
Contributor

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
Copy link
Author

PTz0uAH commented Aug 19, 2024

@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
Copy link
Author

PTz0uAH commented Sep 3, 2024

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

@PTz0uAH PTz0uAH closed this as completed Sep 3, 2024
@PTz0uAH
Copy link
Author

PTz0uAH commented Oct 14, 2024

@licy183 Status & Progress "Wouldn't this be a better option? 100% native.."

Well some final/first words, since creating the FPC debs with termux-create-package first worked but after a python update it does not work anymore.. I worked out an alternative method to create FPC and LAZARUS using the infamous FPCUPDELUXE..

I did put LAZBUILD (Lazarus from commandline) to work and produced a FPCUPDELUXE binary which should be the better or even best option for pascal developers..

Now if we can get FPCUPDELUXE fully working I guess that would be a really nice addition for Termux/X11/GTK2 on XFCE4..

All I need to do now is maintain a "Termuxified" FPCUPDELUXE and the Pascal community can use their Android devices for fun/work/etc. boldly go.. ;-)

fpcupdeluxe-aarch64-android

Isn't this cool? Testers welcome..

with kind regards,

PTz()uAH

@PTz0uAH PTz0uAH reopened this Oct 14, 2024
@PTz0uAH
Copy link
Author

PTz0uAH commented Oct 18, 2024

@licy183 Status & Progress "It took some effort but it works 100% native.."

Hereby I can confirm the FPCUPDELUXE binary works fine albeit building fpc+lazarus from trunk needed a lot of codechanges so there is no out-of-the-box experience yet..

Anyway.. to focus on FPCUPDELUXE, it works but needs some finetuning i.e. to autoinstall Lazarus for XFCE4 but now I first take some quality-time to play around with it..
Screenshot_20241018-124131

with kind regards,
Peter

@licy183
Copy link
Collaborator

licy183 commented Oct 18, 2024

Thanks for your working! Actually I'm not familar with Pascal. I'll have a look if I have more free time.

@twaik
Copy link

twaik commented Oct 19, 2024

There was some work for porting FPC to termux, but it is unfinished. termux/termux-packages#10862

@twaik
Copy link

twaik commented Oct 19, 2024

I think lazarus+fpc may be proposed to termux-packages, not to tur since the work was started there.

@PTz0uAH
Copy link
Author

PTz0uAH commented Oct 21, 2024

@licy183 @twaik
What I have learned the past 57 days is:

  • it is possible to get FPC + Lazarus build for Termux X11/XFCE4/OpenGL aarch64
  • a FPC package is easy to create but it is X11/OpenGL/GTK2 you need for desktop dev so you must build from trunk..
  • so both FPC and LAZARUS sources need to be heavily edited for usage with Termux..
  • that is why FPCUPDELUXE is fundamental to get things going.. and therefore will unpropose a fpc/lazarus package for Termux and propose a "FPCUPDELUXE package including Bootstrapper FPC" for easy start-part-one PLUS a local patcher to adapt the trunk source for Termux.. (another program I develop).. which is fundamental to keep on par with the latest developments..
  • when you commit all needed local edits to the source and (re)build FPC (trunk) first and (re)build LAZARUS (trunk) for X11/GTK2 it will work.. in the end..
  • you can get the FPCUPDELUXE beta from my "Termuxified" page if you want to try it out..
  • it runs on non-root Termux/X11/XFCE4 after having a functional FPC 3.2.2 bootstrapper available and the dependency libs installed.. (ldd fpcupdeluxe-aarch64-android)
  • start it via run.sh script on the path;
#!/data/data/com.termux/files/usr/bin/sh
LD_LIBRARY_PATH=$PREFIX/lib
export LD_LIBRARY_PATH
./$@ &

note: to make it easy just

ln -s path-to/run.sh $PREFIX/bin/run

Assuming you have

$HOME/pascal/fpcupdeluxe-aarch64-android

cd to the location and run it..

cd $HOME/pascal
run fpcupdeluxe-aarch64-android

and you are ready to rock.. fpc creation from trunk will work though be prepared to hack the code.. if you want more..

Finally as another "world premiere" I can also announce to have the Castle Game Engine running so my personal goal was achieved.. but only libopenal.so was installed but not found by CGE so that's a bummer..no sound yet.. (note: vlc works fine though)

So please enjoy some eyecandy aka proof-of-concept-of-proof..

Screenshot_20241021-100637
Screenshot_20241020-145943
Screenshot_20241021-092606
Screenshot_20241021-095650
Screenshot_20241021-100601

with kind regards,
Peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants