KDE4: modicum of success on OpenBSD

Marc Espie espie at nerim.net
Mon Mar 19 21:44:20 GMT 2007


On Mon, Mar 19, 2007 at 09:35:35PM +0100, Thiago Macieira wrote:
> 
> Can you explain how ld finds the library on OpenBSD?
> 
> On Linux and other systems I know about, it looks for libname.so and 
> libname.a. Then it adds the SONAME from the library as the requirement in 
> the target binary.
> 
> Does the OpenBSD linker explicitly list libname.so.*.*, sort it and link 
> against the highest version? Or does it use the .so + symlink trick too?

We still use the old style libname.so.major.minor names.
If you link with -Ldir1 -Ldir2 -Ldir3 -lname
ld will scan its path until it finds one directory with the library, and
it will stop at that directory.

At which point it will get the library with the highest major.minor, and
link it into the executable. If there is a soname, it should be 
libname.so.MAJOR.

At run time, ld.so, will look into its own path, and load a library with
the same major version (meant for API changes) and the highest minor it
can find.

In general, you just dump every library in the same directory, and let
ld find the highest number. In case where we need to link with older
libraries, we provide an extra directory with a link to the old library,
and link with that directory up front in the path. So we use a symlink
trick, but it's not the same as you're used to. ;-)

Most libraries end up in /usr or /usr/local, so the user mostly never
has to touch his ld.so path, and we very rarely use rpath. (it's still
there so if someone wants to make their own bundle in a separate directory,
they can).

As a rule, we are VERY CAREFUL with ABI changes, and we do bump library
major numbers in case of doubt. We finally got around to tweaking build
tools like libtool so that we can bump numbers when needed (which happened
once to all C++ libraries, when we normalized our size_t definition and
ended up changing the mangled names of a lot of functions).




More information about the kde-core-devel mailing list