[fpc-pascal] dynamic libs linux

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Jul 6 00:29:26 CEST 2008


How can I create and load two dynamic libs A and B under linux, that
depend on each other (B uses A)?

For example:
libmy_lib1.so contains the unit lib1unit1.pas with some procs and
variables.
And libmy_lib2.so contains the unit lib2unit1.pas with some procs
using those in libmy_lib1.so.

I used dlopen from dl.pp to load them. That works without problem as
long as lib2 does not use lib1. So I think, that the paths and basic
setup works.
But when lib2unit1.pas uses a variable/procedure of lib1unit1.pas, then
dlopen returns 0.
I tried with -Cg (PIC) and without.

I built the libs with:
fpc -g -Cg -FUlib lib1unit1.pas
cd lib
ppumove -q -o my_lib1 lib1unit1.ppu
ld -shared -E -o libmy_lib1.so lib1unit1.o
rm lib1unit1.o


Mattias



More information about the fpc-pascal mailing list