Recent

Author Topic: [CLOSED] Build app with all dependent library  (Read 2048 times)

incendio

  • Sr. Member
  • ****
  • Posts: 289
[CLOSED] Build app with all dependent library
« on: June 20, 2024, 04:22:47 am »
Hi guys,

I thought Lazarus build app with all dependent library, but I was wrong.

My app didn't run on Ubuntu Server 20 because of missing glib library.

There is an article in this forum to address this issue, but it is to advance for me and this Ubuntu Server is a live server, so I am afraid  to mess around if not sure it will work.

If there an option in Lazarus 2.2.6 Linux to build app with all dependent library?

« Last Edit: June 23, 2024, 04:04:40 am by incendio »

MarkMLl

  • Hero Member
  • *****
  • Posts: 7118
Re: Build app with all dependent library
« Reply #1 on: June 20, 2024, 08:00:27 am »
How on Earth can Lazarus build something related to glib from scratch? It's a completely different project and has to be installed with elevated privilege.

Also the recent thread was specifically about an /unexpected/ version of glib. As I said in that discussion, the issue is that the link stage resolves all symlinks, so if the underlying .so is named differently (through being a different version) you'll have problems.

I also gave a list of suggested solutions, which I suggest you read.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

incendio

  • Sr. Member
  • ****
  • Posts: 289
Re: Build app with all dependent library
« Reply #2 on: June 20, 2024, 08:17:00 am »
First, I don't know how big is glib, my knowledge of Linux is limited.

Also, it was depend on other library, forgot to wrote the library mentioned in the error message.

Is this glib related with gui? Perhaps I can create non gui app to deal with this dependency.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7118
Re: Build app with all dependent library
« Reply #3 on: June 20, 2024, 08:41:49 am »
Is this glib related with gui? Perhaps I can create non gui app to deal with this dependency.

It is the fundamental library required by just about everything.

Look, I can't say I'm happy with the way things are, but it's been put to my by the developers that the mantra is "Write once, compile anywhere". Not "Compile once, run anywhere".

You CANNOT rely on something which is compiled on system A being runnable on system B, unless you distribute it as some sort of containerised or VM image. I went into more detail in the other thread, and plenty has been written elsewhere on Linux administration.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

robert rozee

  • Full Member
  • ***
  • Posts: 155
Re: Build app with all dependent library
« Reply #4 on: June 20, 2024, 11:32:17 am »
hi incendio,
    assuming the problem you are encountering relates to the console error message /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found the simplest solution is to install Lazarus/FPC using the FPCUpdeluxe application found here:
https://github.com/LongDirtyAnimAlf/fpcupdeluxe
with the appropriate settings selected in FPCUpdeluxe to enable symbol name/version translation. i have not done this myself (i use other methods), but have every confidence that it should work.

with Lazarus/FPC appropriately installed using FPCUpdeluxe, generated executable files will then run on older Linux distros without this issue. it would perhaps be helpful if someone could post a walk-through on how to do the installation. TRon? (oops, my mistake, DonAlfredo is the FPCUpdeluxe author)


a simplified background:
the GLIBC authors intended that every call to a GLIBC function should specify both a function name and a version number, with the two separated with an "@" symbol. for example, "dlopen@GLIBC_2.2.5" specifies the function dlopen that was first introduced with GLIBC_2.2.5 (version 2.2.5 of GLIBC). this scheme allowed for new versions of a function to be added over time without breaking backward compatibility; when new versions of a function were deployed, old version(s) would always be kept available within GLIBC. the GLIBC developers have assured me that once a function/version combination is introduced it will never be removed for the life of the target system (for us this is linux on i386 or AMD64).

the fundamental problem arose when the Lazarus authors decided it would be a good idea to leave out the version numbers from all their source code. this 'kinda worked', in that when an executable was created the linker (which is neither a part of GLIBC nor FPC) would automatically append version numbers to GLIBC function names, using the latest it could find on the computer that was building said executable. as far as i have been able to determine, the linker's choice to always use the latest rather than the oldest version seems to be arbitrary.


in the case of dlopen there are at least two version of the function:
dlopen@GLIBC_2.2.5
dlopen@GLIBC_2.34


when the Lazarus libraries that use dlopen were written, only the 2.2.5 version existed. but then in recent years a newer version of dlopen, 2.34, has been added to GLIBC. the Lazarus libraries know nothing of the 2.34 version, but nonetheless end up being linked to it. purely by good fortune, the 2.34 version of dlopen is functionally compatible with the 2.2.5 version.

the same applies to dozens of other functions in GLIBC, and there is no guarantee going forward that an incompatible version of some existing function will never be introduced; if this happens, Lazarus will break.


cheers,
rob   :-)
« Last Edit: June 27, 2024, 05:25:47 am by robert rozee »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1753
Re: Build app with all dependent library
« Reply #5 on: June 20, 2024, 11:56:13 am »
As a sidenote.

I have disabled the possibility/feature of fpcupdeluxe to allow versioned linking against glibc.
It was a compiler hack. And not a very elegant one.
Also, I heard a rumor that one of the core developers of FPC is trying to implement a similar feature.
So, I hope this rumor will become true.

However, when cross-compiling towards Linux, a lot of libraries (versions) are available online.
Just pick a suitable (old) one and you should be good to go on any (newer) Linux system.

https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/crosslibs_all

dbannon

  • Hero Member
  • *****
  • Posts: 2907
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Build app with all dependent library
« Reply #6 on: June 20, 2024, 12:17:21 pm »
incendio, I regularly release my application, tomboy-ng and it runs on all sorts of systems !

My approach is that I keep a Ubuntu 20.04 virtual machine handy and the final build prior to a release is always done on it. The resulting binaries will run, eg, on anything from ubuntu 16.04 through to Ubuntu 24.04

The issue is that some time in 2021, changes were made in glibc such that binaries built on the new version would not run on older systems. U20.04 was the last LTS Ubuntu to be able to make a binary that will run on U20.04 or earlier.

Your "Ubuntu Server 20" is, I take it, U20.04 ?  Probably time you updated it but thats another issue. If you had built your binary there, it would be all good !

Install Virtual Box on your workstation, make a 25G VM and install U20.04, bring it up to date and use it only for release builds. Has other quality benefits too.

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

incendio

  • Sr. Member
  • ****
  • Posts: 289
Re: Build app with all dependent library
« Reply #7 on: June 21, 2024, 05:03:29 am »
Hi guys,

Before I try all your suggestions, I created an VM of Ubuntu server 22.04 and tried to run my app, and got another error of lib dependency.

On Ubuntu 20.04, error on glib, on Ubuntu 22.04 error on libgdk-x11-2.0.so.0.

Even on the latest ubuntu server, this app couldn't run.

Just to make sure, do you know if gui App can run on Ubuntu Server?

TRon

  • Hero Member
  • *****
  • Posts: 2915
Re: Build app with all dependent library
« Reply #8 on: June 21, 2024, 05:32:26 am »
On Ubuntu 20.04, error on glib, on Ubuntu 22.04 error on libgdk-x11-2.0.so.0.

Even on the latest ubuntu server, this app couldn't run.
See tip about deploying applications and dependencies

Quote
ust to make sure, do you know if gui App can run on Ubuntu Server?
Does ubuntu server come with x installed ?

edit: added link to wikipedia article x to make sure as TS stated to have limited Linux knowledge.
« Last Edit: June 21, 2024, 06:05:59 am by TRon »

Thaddy

  • Hero Member
  • *****
  • Posts: 15202
  • Censorship about opinions does not belong here.
Re: Build app with all dependent library
« Reply #9 on: June 21, 2024, 06:45:15 am »
Does ubuntu server come with x installed ?
No, but it can of course be installed manually. Servers generally do not have GUI software installed, although X has also other purposes. The good news - and bad news for the sysop -is that if you install fpc from the default repository, X will be installed as a dependency. On Ubuntu 22 or higher it will be fpc 3.2.2 along with a whole host of other dependencies. Sysop's don't like that.
For that reason it is also important  to ask the sysop/sysadmin if it is allowed to run GUI software on the server directly instead of on a controlling client. The answer is often NO.
As a side note: Ubuntu does not always play nice and defaults to Wayland as Window manager which has some problems - paint issues - with some software, not only software written in Freepascal.(e.g. Geany has the same problems as Handoko multiple times described)
« Last Edit: June 21, 2024, 07:00:12 am by Thaddy »
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

incendio

  • Sr. Member
  • ****
  • Posts: 289
Re: Build app with all dependent library
« Reply #10 on: June 21, 2024, 06:58:15 am »
I am pretty sure that this Ubuntu Server doesn't come with X installed, and won't be installed either.

The server is a firebird database server. My app is a small utility to backup and restore database for dummies users.

I came up with an idea, please suggest me if this is do able.

Instead of doing some troublesome to make my app runs on Ubuntu, I will make my app runs on Windows and do a remote backup/restore via Windows to Ubuntu Server. Is this possible?

Thaddy

  • Hero Member
  • *****
  • Posts: 15202
  • Censorship about opinions does not belong here.
Re: Build app with all dependent library
« Reply #11 on: June 21, 2024, 07:04:27 am »
If you read my reply carefully you would know: Write client software to control the server through another computer. The server part does not need a GUI, just the client.
It should be quite easy to instruct the firebird database on the server to do a back-up through a client on a different computer. This is usually how it is done anyway. It is the core architecture of servers.
I am not that familiar with Firebird, but it should be one very simple SQL statement to create a back-up. For software that performs such operations from a client I usually issue task specific certificates so only people/machines that have the appropiate certificate can actually perform the back-up. It is also a good idea to choose a different port from the default.
« Last Edit: June 21, 2024, 07:16:44 am by Thaddy »
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

TRon

  • Hero Member
  • *****
  • Posts: 2915
Re: Build app with all dependent library
« Reply #12 on: June 21, 2024, 07:15:53 am »
I am pretty sure that this Ubuntu Server doesn't come with X installed, and won't be installed either.
That is fair enough but without X (or any other graphics layer) how do you expect a Lazarus GUI program compiled against GTK to be able to run /on that server/ ?

Quote
I came up with an idea, please suggest me if this is do able.
Ofc that is do-able but without a graphical shell you can't run a GUI app /on/ the server itself. It would be the same as you would try and run any other GUI application (such as for example gimp or VLC)

If we would translate that somewhat to Windows terminology: if you run MS-DOS would you expect that be to be able to run f.e. irfanview or FireFox. The answer is the same: no, because you are missing a fundamental part to be able to run and display GUI applications in MS-DOS (and I am not referring to graphics in the sense of games there  :) ).

Quote
Instead of doing some troublesome to make my app runs on Ubuntu, I will make my app runs on Windows and do a remote backup/restore via Windows to Ubuntu Server. Is this possible?
Yes, but the same is possible for Linux. It seems to me that you misunderstood the problem(s) and suggested approaches to solve them ?

Thaddy

  • Hero Member
  • *****
  • Posts: 15202
  • Censorship about opinions does not belong here.
Re: Build app with all dependent library
« Reply #13 on: June 21, 2024, 07:18:16 am »
Quote
Instead of doing some troublesome to make my app runs on Ubuntu, I will make my app runs on Windows and do a remote backup/restore via Windows to Ubuntu Server. Is this possible?
Yes, but the same is possible for Linux. It seems to me that you misunderstood the problem(s) and suggested approaches to solve them ?
That is exactly my advice too. Yes that is not only possible, but how it is done anyway.
About my port remark: I don't know if Firebird can listen to multiple ports, but you can setup a reverse proxy on the server. The idea is to have a strict separation of administrative tasks from end-user tasks.
« Last Edit: June 21, 2024, 07:30:42 am by Thaddy »
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

TRon

  • Hero Member
  • *****
  • Posts: 2915
Re: Build app with all dependent library
« Reply #14 on: June 21, 2024, 07:58:20 am »
No,
It was kinda meant as rhetorical question for TS  :) But you are right in that I forgot that you can install it manually (later).

@incendio
Just like Thaddy (I presume) I hardly know anything about firebird servers but I am aware of this article from Michaël Van Canneyt and which, after a little research, makes me believe that you have 2 options to make backups (gbak and nback) and neither of them seem to allow for a remote backup.

Basically you would automate the backup as described in the article and then you could choose to use FTP protocol or something similar to download the backup. A similar approach can be taken for restoring a backup (but in reverse order, first upload local stored backup to the server and auto restore the database on the server). If you have f.e. a httpserver running on that same server you could opt for a html page with backup /restore option for your database. There are a plethora of approaches possible depending on what is (already) running on your server (or that you are allowed to run).
« Last Edit: June 21, 2024, 08:12:21 am by TRon »

 

TinyPortal © 2005-2018