[fpc-pascal] Defining sonames?
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Thu Aug 17 15:49:28 CEST 2017
On 2017-08-16 18:14, Sven Barth via fpc-pascal wrote:
> As you can see the program will work correctly as long as the
> libX11.so.6 file exists (even though that is a symlink itself, but the
> X11 project guarantees that different libX11.so.6.x.y are compatible to
> eachother), because the linker picks the SONAME that is set inside the
> binary. And the libX11.so.6 symlink is part of the non-devel package.
Sven, now here is an interesting problem regarding the way FPC (or
Object Pascal in general) works with C based libraries. Martin pointed
this out in another mailing list, and he gave me permission to forward
it here. What is your answer or recommendation to this problem?
-------- Forwarded Message --------
Subject: Re: [MSEide-MSEgui-talk] MSE and XLib.
Date: Thu, 17 Aug 2017 14:54:16 +0200
From: Martin Schreiber
To: mseide-msegui-talk at lists.sourceforge.net
On Thursday 17 August 2017 10:54:31 Graeme Geldenhuys wrote:
> On 2017-08-17 07:18, Martin Schreiber wrote:
> > I don't understand why FPC uses the version-less library
> > names instead of the mayor version names where the bindings are
made for.
> > Maybe a misunderstanding happened at ancient times...
>
> No, they are simply following the guidelines of Unix-type systems -
> doing everything correctly by the book.
A hypothetical example:
- You make a pascal bindings file for the "greatlibrary" version 1.0.
- You set the library name in the bindings pascal file "great.pas" to
"great" as Unix-type systems guidelines command.
- In your system great-devel package of the version 1.0.1 is installed,
you have the c-header *.h files of libgreat 1.0.1 and the links
libgreat.so -> libgreat.so.1 -> libgreat.so.1.0.1.
- The SONAME of libgreat.so.1.0.1 is libgreat.so.1
- You compile and run the application, libgreat.so.1 ->
libgreat.so.1.0.1 is loaded, all is OK.
Now you give the source of the application to a colleague who has
installed the newer but incompatible "greatlibrary" version 2.0.3
including the devel package.
- He has the c-header *.h files of libgreat 2.0.3 and links libgreat.so
-> libgreat.so.2 -> libgreat.so.2.0.3.
- The SONAME of libgreat.so.2.0.3 is libgreat.so.2
- He compiles your program, the linker links libgreat.so ->
libgreat.so.2 -> libgreat.so.2.0.3 and stores the SONAME libgreat.so.2
(remember, libgreat.so.2 and libgreat.so.1 are *not* compatible).
Now there are two possibilities, maybe the function names in
libgreat.pas did not change between version 1 and 2 -> the program
compiles but crashes because of changed parameters or other
incompatibilities.
Or it does not compile and then he needs to install version 1 of
"greatlibrary" and deinstall great-devel-2.0.3 and install
great-devel-1.0.1 or change manually libgreat.so -> libgreat.so.2 to
libgreat.so -> libgreat.so.1 temporarily.
This also must be done in first case in order to produce a working
application.
The difference between a FPC bindings unit and a Unix C-header *.h file
is that the *.h file is *included* in the devel-package and thus matches
the installed version, the pascal file is not included but in a separate
package or more likely taken from the FPC tar archive by the FPC install
script because FPC Linux/FreeBSD-packages usually are too old or one
wants to use a FPC version from SVN.
So the "guidelines for Unix-type systems" are not appropriate for Free
Pascal C-library binding units IMHO.
Martin
---------------------------------------------------
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal
mailing list