[gccsdk] Shared Library confusion
leenoar at sky.com
Wed Sep 9 09:53:56 PDT 2009
alan buckley wrote:
> I had looked at SharedLibraries for packaging for a while
> and it seems to me that for a SharedLibrary you need to
> create the full version library (e.g. libY/so/1/2) then create
> symlinks libY/so/1 and libY/so. These should all be installed
> to !SharedLibs.
Yes, that's correct and the standard convention.
> I believe static libraries for RISC OS should be installed
> in the standard RISC OS way. i.e. An application directory
> that sets the location of them.
> Unfortunately I can't remember the linux convension
> or how GCC works. I think you always link to libY/so
> and the runtime will then use the libY/so/1 to resolve
> it at run time or have I missed something or got that
> the wrong way round?
When you build a shared library, you use the static linker flag -soname
to set the DT_SONAME entry in the dynamic segment of the library (which
you can view using readelf -d). This will be of the form libY/so/1. When
you build an executable/library (the target) that depends of this
library, you specify it on the link line as -lY. The static linker will
look for libY/so which is a symlink to the library itself. The static
linker will look at DT_SONAME of libY/so and use that to create a
DT_NEEDED entry in the target. This is what the dynamic loader uses at
runtime to find the library. If the dependent library was not built
using -soname, then the static linker uses the filename that the library
was created with to determine what goes in the DT_NEEDED entry of the
target. This will be in the form libY/so (actually libY.so). In either
case, libY/so/1 and libY/so should ideally exist as symlinks to libY/so/1/2.
> Anyway I think it lead to a static link line with flags:
> -LLibY: -ly
> and a shared link line something like:
> -L/SharedLibs:lib/ -ly
> But I too would like clarification on this.
You shouldn't need to specify -L/SharedLibs:lib/ as RISC OS GCC
automatically searches GCCSOLib: which !SharedLibs sets in its !Run file.
More information about the gcc