[fpc-pascal] Static linking to C library on Linux
Karoly Balogh (Charlie/SGR)
charlie at scenergy.dfmk.hu
Wed Nov 27 17:25:26 CET 2019
Hi,
On Wed, 27 Nov 2019, Ryan Joseph via fpc-pascal wrote:
> I'm trying to link to a static library (built from Python sources) in
> Pascal and having troubles on Linux. On Mac where I have experience I
> successfully link and every works as expected but on Linux I get slews
> of linker errors in what appear to be standard C library functions.
> (snipp)
> Do I need to link to other system libraries when building on Linux?
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.
> I'm also confused because I thought the purpose of the static libraries
> was to contain all the code they needed to run and thus these system
> functions like "memcpy" would be present also.
That's not true. Static libs can depend on other static libs, just the
resulting final executable won't depend on anything if statically linked.
Hope this helps,
--
Charlie
More information about the fpc-pascal
mailing list