[fpc-pascal] Static linking to C library on Linux
Karoly Balogh (Charlie/SGR)
charlie at scenergy.dfmk.hu
Wed Nov 27 18:10:51 CET 2019
Hi,
On Wed, 27 Nov 2019, Ryan Joseph via fpc-pascal wrote:
> > On Nov 27, 2019, at 11:25 AM, Karoly Balogh (Charlie/SGR) <charlie at scenergy.dfmk.hu> wrote:
> >
> > Yes. By Default, FPC doesn't link against libc on Linux by default, only
> > when some more advanced things, say, threading is used. To the contrary on
> > Darwin (macOS), we always link against libc. There comes your difference
> > from. You can just try to add {$LINKLIB C} to your code, and see if that
> > helps.
>
> Thanks that makes sense now. {$LINKLIB C} did help some of the errors
> but I'm still getting others. I'm aware of 'ldd' to show dependancies
> for dynamic libraries but how can I do this for static libraries on
> Linux? I'm getting defined references for math functions like pow, cos
> etc.. and some pthread ones also. There's probably more but how can I
> know?
I don't know anything like that for static libs... But maybe it exist
somehow. You probably also need libm (for pow/cos), and then for the
pthreads I'd just include "uses cthreads" in my uses clause, as that will
take care of pthreads, and integrating FPC into whatever threading going
properly.
There is no silver bullet, if you Google the missing symbols you can work
your way through what library is needed. Or if you look at some C example
from the static library you're trying to use, its makefile will probably
list the additional libraries it depends on.
Charlie
More information about the fpc-pascal
mailing list