[fpc-pascal] Problem linking external libs on Linux

Anthony Walter sysrpl at gmail.com
Sun May 12 18:40:18 CEST 2019

I'm am not sure how long I've ignored this problem, but can someone explain
to me the proper way to get FPC and Lazarus to allow linking of external
shared object files without the need to create "friendly" symbolic link
names FPC and Lazarus can see?

For example suppose I want to write some pascal code linking to an external
functions like so:

  libsdl2 = 'libSDL2-2.0.so.0';

function SDL_Init(flags: Uint32): LongInt; cdecl; external libsdl2;
procedure SDL_Quit; cdecl; external libsdl2;

And when I try to compile the linking will likely failed because something
is happening where the libsdl2 constant of 'libSDL2-2.0.so.0' is being
converted to 'SDL2-2.0' at some point during the compilation or linking
stage when working on Linux.

It is taking the constant, removing and 'lib' prefix, and anything after a
'.so.'. So it's losing the '.0' at the end of my constant.

If I create symbolic link on my system like so, then the compilation and
linking works:

sudo ln -s /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 /usr/lib/
 - or alternately -
sudo ln
-s /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 /usr/lib/x86_64-linux-gnu/

But I don't feel this is correct. I should be able to explicitly specify
the standard name of the file name for the library which is
'libSDL2-2.0.so.0' and the compilation and linking stages should be able to
use it with the '.0' at the end.

So my question is, what do I need to do either in Lazarus settings,
fpc.cfg, or some other setting (possibly on my OS) to allow
'libSDL2-2.0.so.0' to work as a valid external library name without the
need to create symbolic links?

By the way, I am using Ubuntu 16.4 64 bit if that is at all relevant.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190512/d129f128/attachment.html>

More information about the fpc-pascal mailing list