[fpc-devel]Library linking with C explanation

Peter Vreman peter at freepascal.org
Tue Jun 19 13:55:16 CEST 2001


> >> Reply-To: core at freepascal.org
> >> Date: Sun, 3 Jun 2001 15:12:42 +0200 (CEST)
> >> From: Peter Vreman <pfv at cooldown.demon.nl>
> >> X-Sender: pfv at dell
> >> To: core at freepascal.org
> >> Subject: Library linking with C working !
> >>
> >>
> >> It was more easy than i first thought. No need for .ctor and .dtor
> >> stuff. Just pass "-init <Symbolname>" to the linker and the symbol to
> >> run at load of the library is set. The same for -fini.
> >>
> >> The 1.0.5 compiler works correctly.
> 
> Congratulation!
> We speak about last variant of 1.0.5 -- that is right?
> FPC 1.0.5 from 14 march 2001 do not works correctly.
> 
> >>  The 1.1 compiler crashes at exit
> >> when the pas1 function is called from p.c. If the function call is
> >> left away then the progrma shuts down correctly.
> >>
> >> 1. Compile p1.pp normally
> >> 2. Move libp1.so to /usr/lib or any other path searched by ldconfig
> >> 3. Run ldconfig
> >> 4. Compile p.c with: 'gcc -o p p.c -lp1'
> >> 5. Run the program.
> 
> This can be done simpler (comands are for DCC from Kylix):
> 1) dcc p1.pp
> 2) gcc -o p p.c libp1.so
> 3) LD_LIBRARY_PATH=`pwd` p

But most ppl will just try to start the file and forget about the LD_LIBRARY_PATH thing.







More information about the fpc-devel mailing list