Recent

Author Topic: Compile on multiple distros of Linux?  (Read 1491 times)

dodgebros

  • Full Member
  • ***
  • Posts: 168
Compile on multiple distros of Linux?
« on: January 21, 2025, 01:36:53 am »
I have Lazarus installed on Linux Mint.  I copied all the project files over from my Lazarus on Windows 7.  Once I compiled my "Windows" Lazarus project files on Linux Mint it worked perfectly on Mint.  BTW i am using the Ubuntu derivative of Mint.

As a test I installed the latest workstation version of Fedora in a virtual machine then copied the compiled program file from Mint to Fedora and made it executable.  When I double click on the compiled program file on Fedora, nothing happens.

I said all of that to ask this question....does one have to compile the Lazarus project on EACH Linux distro in order to get it to work?

Thanks,
TD

TRon

  • Hero Member
  • *****
  • Posts: 4133
Re: Compile on multiple distros of Linux?
« Reply #1 on: January 21, 2025, 02:05:23 am »
I said all of that to ask this question....does one have to compile the Lazarus project on EACH Linux distro in order to get it to work?
No but with some caveats (which probably makes the no answer a theoretical one unless knowing what you're doing).

The host platform must provide the dependencies that your application depends on. E.g. if you compiled your program for QT5 widgetset then it will ofc not run on a host that does not cater for that dependency.

Furthermore, wayland vs X11 can be an issue and in a similar fashion the version of libc which was build against.

The versions of the libraries that you build against are important (the host must be able to handle them).

Other than that, in theory, you should be good to go.

A GUI application can be invoked from a terminal and usually provide an error on what is missing. Detailed information can be obtained with strace.
« Last Edit: January 21, 2025, 02:09:19 am by TRon »
Today is tomorrow's yesterday.

Thaddy

  • Hero Member
  • *****
  • Posts: 16638
  • Kallstadt seems a good place to evict Trump to.
Re: Compile on multiple distros of Linux?
« Reply #2 on: January 21, 2025, 06:31:40 am »
You only have to resolve the dependencies (and compile for the right cpu, of course)
Lazarus GUI applications can have *a lot* of dependencies, mainly the widget set.
Text mode applications or Daemons have very few to none.
The wayland vs X11 warning from TRon is something to be aware of, especially when you are not fully up-to-date:wayland is a moving target.
But I am sure they don't want the Trumps back...

dbannon

  • Hero Member
  • *****
  • Posts: 3294
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compile on multiple distros of Linux?
« Reply #3 on: January 21, 2025, 09:28:37 am »
Guessing you have built a gtk2 app on your linux box, here are the libraries I declare in packaging as necessary for my (gtk2) app -

libgtk2.0-0, libcanberra-gtk-module, libnotify-bin,

I strongly doubt you need libnotify and you probably don't need libcanberra but my app complains if its not there (runs OK but grizzles).  So, probably, all you need is libgtk2.0-0 !

On fedora, possibly -

Code: Bash  [Select][+][-]
  1. $> sudo dnf install libgtk2.0-0 <enter>

There was a time when every distro included gtk2 by default but we have been getting signals that it is time to give up on it for some time.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Handoko

  • Hero Member
  • *****
  • Posts: 5396
  • My goal: build my own game engine using Lazarus
Re: Compile on multiple distros of Linux?
« Reply #4 on: January 22, 2025, 03:17:29 am »
As Windows, programs written using Linux may have library dependency issue. One can use ldd command to check which library is missing.

dodgebros

  • Full Member
  • ***
  • Posts: 168
<RESOLVED> Re: Compile on multiple distros of Linux?
« Reply #5 on: January 23, 2025, 05:44:44 am »
Guessing you have built a gtk2 app on your linux box, here are the libraries I declare in packaging as necessary for my (gtk2) app -

libgtk2.0-0, libcanberra-gtk-module, libnotify-bin,

I strongly doubt you need libnotify and you probably don't need libcanberra but my app complains if its not there (runs OK but grizzles).  So, probably, all you need is libgtk2.0-0 !

On fedora, possibly -

Code: Bash  [Select][+][-]
  1. $> sudo dnf install libgtk2.0-0 <enter>

There was a time when every distro included gtk2 by default but we have been getting signals that it is time to give up on it for some time.

Davo

That resolved the issue as the app now runs on fedora 41.   Thank you !!!

HotShoe

  • New Member
  • *
  • Posts: 39
Re: Compile on multiple distros of Linux?
« Reply #6 on: February 19, 2025, 10:10:20 pm »
You can also see what libraries are absolutely required using :

objdump -x filename | grep NEEDED

--- Jem

duralast

  • New Member
  • *
  • Posts: 31
Re: Compile on multiple distros of Linux?
« Reply #7 on: February 19, 2025, 10:29:03 pm »
Use the OpenSUSE Build Service to use the same source to compile for multiple Linux distros.

dodgebros

  • Full Member
  • ***
  • Posts: 168
Re: Compile on multiple distros of Linux?
« Reply #8 on: February 19, 2025, 10:54:04 pm »
Looks awesome, thank you !!!

PeterBB

  • Jr. Member
  • **
  • Posts: 56
Re: Compile on multiple distros of Linux?
« Reply #9 on: March 04, 2025, 11:31:45 pm »
Use the OpenSUSE Build Service to use the same source to compile for multiple Linux distros.

I was going to mention that too. Example
https://build.opensuse.org/package/show/home:PeterBBB/c-evo

Builds for 3 versions of Debian, 6 of Ubuntu, Fedora, Mageia from the same source package.

Rather ironically, the only build fail is on openSUSE  :D

dbannon

  • Hero Member
  • *****
  • Posts: 3294
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Compile on multiple distros of Linux?
« Reply #10 on: March 05, 2025, 07:43:21 am »
Peter, I am puzzled, are you building, for example, different binaries for Ubuntu 22.04 and Debian Bookworm ?  I offer users exactly the same deb package for all deb using x86_64 systems (eg), no problems.

Certainly looks a useful platform ...

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 8315
Re: Compile on multiple distros of Linux?
« Reply #11 on: March 05, 2025, 09:03:56 am »
As Windows, programs written using Linux may have library dependency issue. One can use ldd command to check which library is missing.

The fundamental problem is that the linker generally resolves symlinks to actual library names, so the loader is intolerant of even a trivial version change.

It's hardly helped by the fact that Linux doesn't tell you what's actually wrong, just fails silently.

OP: if you want to mark the thread <RESOLVED> or similar, you'll have to edit that into the subject line of the initial posting.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PeterBB

  • Jr. Member
  • **
  • Posts: 56
Re: Compile on multiple distros of Linux?
« Reply #12 on: March 07, 2025, 02:58:24 pm »
....
are you building, for example, different binaries for Ubuntu 22.04 and Debian Bookworm ? 
....

Hi Davo,

the executables are different, and the binary packages are not even the same size.

Cheers,
Peter


 

TinyPortal © 2005-2018