[fpc-pascal] Is it possible to link to SO libraries that have filename ending like '.so.0'

Pedro Lopez-Cabanillas plcl at telefonica.net
Wed Jan 5 20:31:45 CET 2005


Hi, 

On Wednesday 05 January 2005 16:49, Michalis Kamburelis wrote:
> So it seems that fpc passes to ld -lSDL-1.2, and ld looks for
> 'libSDL-1.2.so' (without '.0' suffix). Honestly, I don't know what one
> should pass to ld to tell it to link to 'libSDL-1.2.so.0'.
>
> Question: Can this be somehow fixed in FPC ? Or is it just impossible
> for FPC to say such thing to ld (so we have another problem that can't
> be solved because FPC uses external linker) ?
>
> In another words, should this be considered something that must be fixed
> in JEDI-SDL (by changing lib name back to 'libSDL.so') or can this be
> fixed in newer FPC versions ? Or maybe it's all already working, but I
> have to pass some command-line parameter to FPC or use some {$...}
> preprocessor directive to make it work ?

IMHO, FPC behaves right and matches with other UNIX's compilers, like GCC. In 
fact it is the "ld" linker behavior, not the compiler.

You should tell to the linker to bind your program against a generic library 
'libSDL.so', and then it will find the real "soname", that will be extracted 
from the real library and stored into your program, so the dynamic loader 
(ld-loader) will be able to find the right library at run time. I mean:

You can have two versions of some library in your system, say:
/usr/lib/libFOO.so.1.0.0 and /usr/lib/libFOO.so.2.0.0; but only one symlink 
/usr/lib/libFOO.so pointing to any of them. You only need this symlink to 
compile programs, not to execute them. This means that even if you have 
several versions, you only develop programs for one version at a time. The 
liker extracts from the real library file the "soname" symbol, that is 
usually something like "libFOO.so.2", including the major version name. This 
symbol is included in your program, and will be used to find the real library 
that should be loaded at runtime. You can test the sonames for a program with 
the "ldd" utility.

Compare with GCC:
http://ww.telent.net/linux/GCC-HOWTO-6.html#index.73

Regards,
Pedro








More information about the fpc-pascal mailing list