[Lazarus] version `GLIBC_2.34' not found error when running app on different PC

Michael Van Canneyt michael at freepascal.org
Fri Mar 17 08:43:55 CET 2023

On Fri, 17 Mar 2023, Bo Berglund via lazarus wrote:

> On Fri, 17 Mar 2023 08:53:01 +0300, Mehmet Erol Sanliturk via lazarus
> <lazarus at lists.lazarus-ide.org> wrote:
>> Some portability is obtained if the libraries are linked as "static" .
>> If "dynamic" linking is selected , during execution of the program ,
>> the "same" library should be in the executing computer .
> How is this accomplished in Lazarus?

You need to change the units that refer to other libraries so they use
static linking.

> Does this change happen randomly or is it connected to the major Ubuntu releases
> like going from 20.04 to 22.04 rather than just keeping 20.04 up-to-date?

It is unpredictable, but will mostly happen in major releases of linux

> It implies having to build applications on as old a system as ever possible,
> maybe using 16.04 or earlier just for making apps that can run on all systems,
> is that really true?

No, this will not help you, as then you will have another problem: old
libraries installed on such systems may not exist on newer systems.

> It makes no sense to me...

Why not ?

It's perfectly simple. Distributions changed the libraries which they
ship, and the libraries are no longer compatible.

> And from https://wiki.freepascal.org/Lazarus/FPC_Libraries
> ------------------------------------------------------------------------------
> Static linking
> FPC compiles and links a static executable by default. That means it tells the
> linker to put all .o files of the project and all packages into one big
> executable.
>    Advantages:
>        No external dependencies.
>    Disadvantages:
>        No code is shared between different programs on the same computer.
>        You can not load/unload a plugin.
> -------------------------------------------------------------------------------
> This idea was always why I liked Delphi when it came along in 1995 or so, just
> build an executable and it could be run everywhere.
> This is also why I liked FreePascal when it appeared because I did not need to
> bother with distributing extra files all over the place.
> So why has it changed now and how can I get around it?

FPC has not changed. It still works the same. 
Everything that is under control of FPC is linked statically.

But a complex GUI system like the LCL uses GTK/GDK/Qt and other libraries, 
and those are dynamic, external libraries over which FPC or lazarus has no control.

If you use a unit that relies on LibC somewhere, you automatically depend on the libc

> Developing on an up-to-date system should ensure the output could work
> everywhere, but not so now it appears....

No-one can ensure this. It was never so. It used to be worse in the past.

Distributions change, and sometimes break binary compatibility. 
This means you must cater for that.

There are roughly 2 ways:
- Compile on a system that has the correct version of libraries as on the
   target computer.
- Distribute the needed libraries with your executable.

> I cannot find any setting for this in Lazarus.

This cannot be solved with some setting.

> Notice: This is a command line utility so it needs no access to any GUI
> components at all...

You use libc through some unit that is included in your sources. The libc
library on both systems you tested on differ too much, that is why you have
the error.


More information about the lazarus mailing list