Recent

Author Topic: Tips for cross-compiling a GUI Application to Linux?  (Read 608 times)

Cascade

  • Jr. Member
  • **
  • Posts: 65
Tips for cross-compiling a GUI Application to Linux?
« on: November 09, 2025, 05:40:48 pm »
I'm trying to cross-compile an LCL app from macOS to Linux.

Linux Fedora 43 (Arm) is installed in a VM and running OK.  When I execute a native Arm or emulated x86 application I see the following two errors respectively in Console and the app fails to start (screenshot attached).  The project in Lazarus indicates it is using the LCL GTK2 widget set for the Linux target.

Although I did encounter X11 on macOS a long time ago, I'm not sure how it relates to Linux.

Any tips?

Edit: 
Code: [Select]
file TabBarDemo
TabBarDemo: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.0.0, stripped

32-bit 🤔  I imagine I'd want 64-bit these days.
« Last Edit: November 09, 2025, 05:52:56 pm by Cascade »

Cascade

  • Jr. Member
  • **
  • Posts: 65
Re: Tips for cross-compiling a GUI Application to Linux?
« Reply #1 on: November 09, 2025, 09:45:02 pm »
I think I'm slightly confused, but it looks like the 64-bit version of ARM is called Aarch64

I was under the, likely mistaken, impression that Aarch64 referred only to Apple Silicon architecture, but perhaps it's more general.

After removing the linux-arm cross-compiler, and replacing it with a linux-aarch64 compiler, both native and x86 executables give the same error (progress!  ::))

Code: [Select]
error while loading shared libraries: libgdk-x11-2.0.so.0: cannot open shared object file: No such file or directory

Thausand

  • Sr. Member
  • ****
  • Posts: 437
Re: Tips for cross-compiling a GUI Application to Linux?
« Reply #2 on: November 09, 2025, 10:14:24 pm »
I think I'm slightly confused, but it looks like the 64-bit version of ARM is called Aarch64

I was under the, likely mistaken, impression that Aarch64 referred only to Apple Silicon architecture, but perhaps it's more general.
Yes arm64 also name aarch64. Wikipedia know  ;D https://en.wikipedia.org/wiki/AArch64
Quote
AArch64, also known as ARM64, is a 64-bit version of the ARM architecture family, a widely used set of computer processor designs.
aarch 64 have exist when apple silicon  not know it go exist.


Code: [Select]
error while loading shared libraries: libgdk-x11-2.0.so.0: cannot open shared object file: No such file or directorygtk is graphical toolkit. Have read again wikipedia https://en.wikipedia.org/wiki/GTK

It is for make work and draw widget for desktop. Lazarus have support different toolkit (depend platform). OS have own toolkit, windows have windows, linux have gtk/qt, macos have other. There more. FPC wiki have article what is support https://wiki.freepascal.org/Widgetset

When no widget then have simple result: no graphic interface.

How install gtk (and dependency) can read and is specific for distribution Linux. That have instruction how to make. When have eror like you then is missing library (dependency). Lazarus wiki is tell what is require dependency and is depend platform.

Cascade

  • Jr. Member
  • **
  • Posts: 65
Re: Tips for cross-compiling a GUI Application to Linux?
« Reply #3 on: November 09, 2025, 10:20:35 pm »
Thank you Thausand, that makes sense  :).

This is probably a naive question - but does Linux generally come with widget set support 'out-of-the-box' ?  I'm guessing it has something already for the operating system UI and built in apps.  But is there something I can generally rely on to always be there for anyone running a (non-minimal) Linux install?

Or put another way - which widget set is most likely to just work on Linux?  (I will now go read the FPC wiki link you suggested - as it may well answer this).  Thanks again!

Thausand

  • Sr. Member
  • ****
  • Posts: 437
Re: Tips for cross-compiling a GUI Application to Linux?
« Reply #4 on: November 09, 2025, 10:37:50 pm »
yw Cascade  :)

This is probably a naive question - but does Linux generally come with widget set support 'out-of-the-box' ?  I'm guessing it has something already for the operating system UI and built in apps.  But is there something I can generally rely on to always be there for anyone running a (non-minimal) Linux install?
Yes and no. Most distribution linux have more version that can download for install. When install linux server is most use for not have a desktop (and then no gtk or qt). Linux desktop (example kUbuntu) have desktop KDE and have widget library pre-install.

Quote
Or put another way - which widget set is most likely to just work on Linux?  (I will now go read the FPC wiki link you suggested - as it may well answer this).  Thanks again!
Nw is come difficult part understand linux: There no standard. There different display server (x11/wayland/etc) different window manager (marco, icewm, etc) and can have mix-match.

Is other thing important when make development linux. Install dependency then have also development dependency. All linux package have also development version for package. This is need so compiler can know where can find dependency: You error have say: missing libgdk-x11-2.0.so.0. You have note character last is zero number ? That is version and compiler have need for find version that is need for FPC/Lazarus. But that specific for distribution base Debian. Other Linux have other base Linux and is work different.

There is small list dependency Lazarus in wiki : https://wiki.freepascal.org/Installing_Lazarus_on_Linux

It is write "for install Lazarus ON Linux" but is not all correct. Is also need for run application that is cross-compile. Depend on what application is require (you have develop application so have know if fi application depend library sqlite or widgetset qt and then library that is part for qt widgetset).

My write very short introduct for Linux. Is require many read for understand (I some time no have clue and have use Linux > 10 year)  :).
« Last Edit: November 09, 2025, 10:43:12 pm by Thausand »

Cascade

  • Jr. Member
  • **
  • Posts: 65
Re: Tips for cross-compiling a GUI Application to Linux?
« Reply #5 on: November 09, 2025, 11:28:35 pm »
There no standard.

Understood! :)

I've had a read of the FPC Wiki you linked to above.  Seems GTK2 is a large size dependency, so instead I first tried to cross-compile for GTK3 (since Fedora Gnome includes GTK3 & 4 by default).

Couldn't get Lazarus to compile for GTK3 - it failed at the linking stage:

Code: [Select]
Error: … cross/bin/aarch64-linux/aarch64-linux-ld: cannot find -lgtk-3: No such file or directory
Error: … cross/bin/aarch64-linux/aarch64-linux-ld: cannot find -lgdk-3: No such file or directory
Error: … cross/bin/aarch64-linux/aarch64-linux-ld: cannot find -lcairo-gobject: No such file or directory
Error: … cross/bin/aarch64-linux/aarch64-linux-ld: cannot find -lgio-2.0: No such file or directory
Error: … cross/bin/aarch64-linux/aarch64-linux-ld: cannot find -lharfbuzz: No such file or directory
Error: … cross/bin/aarch64-linux/aarch64-linux-ld: cannot find -lharfbuzz-gobject: No such file or directory
Error: … cross/bin/aarch64-linux/aarch64-linux-ld: cannot find -lpangocairo-1.0: No such file or directory

But I had better luck with Qt5.  Fedora Gnome needed Qt5 support installing, but it's smaller than GTK2.

And the app ran successfully on Linux Fedora Gnome :)

The Qt5 UI controls themselves seem OK.  But graphics such as icons appear low resolution - too low DPI, so I will have to experiment.  Maybe Qt5 doesn't support HighDPI images?

Thausand

  • Sr. Member
  • ****
  • Posts: 437
Re: Tips for cross-compiling a GUI Application to Linux?
« Reply #6 on: November 09, 2025, 11:58:59 pm »
I've had a read of the FPC Wiki you linked to above.  Seems GTK2 is a large size dependency, so instead I first tried to cross-compile for GTK3 (since Fedora Gnome includes GTK3 & 4 by default).
I have admit not have development experience fedora core.

Is true, desktop widget is big dependency. qt is except.

Quote
Couldn't get Lazarus to compile for GTK3 - it failed at the linking stage:
No xp is also mean I no can help  :'( But many programmer skill on forum that may be can ?

Quote
The Qt5 UI controls themselves seem OK.  But graphics such as icons appear low resolution - too low DPI, so I will have to experiment.  Maybe Qt5 doesn't support HighDPI images?
Have quick search and have give thread (have try suggest and see if work/understand how do dpi for qt): https://forum.lazarus.freepascal.org/index.php/topic,72293.0.html (if forum have set sessionid for link then have remove session id or have search forum "Scaling the QT 5 application" and user zeljko (is person main development libqt5/6pas)

Seenkao

  • Hero Member
  • *****
  • Posts: 718
    • New ZenGL.
Re: Tips for cross-compiling a GUI Application to Linux?
« Reply #7 on: November 10, 2025, 09:25:29 am »
This is probably a naive question - but does Linux generally come with widget set support 'out-of-the-box' ?  I'm guessing it has something already for the operating system UI and built in apps.  But is there something I can generally rely on to always be there for anyone running a (non-minimal) Linux install?

Or put another way - which widget set is most likely to just work on Linux?  (I will now go read the FPC wiki link you suggested - as it may well answer this).  Thanks again!
В большинтсве случаев приложения основанные на X11 должны работать на многих компьютерах с Linux.

Возможно у вас отсутствует установленный пакет dev (libgdk****.dev).

Google translate:
In most cases, X11-based applications need to run on many Linux computers.

You may not have the dev (libgdk****.dev) package installed.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

 

TinyPortal © 2005-2018