[fpc-devel]Library linking with C explanation

Peter Vreman pfv at cooldown.demon.nl
Mon Jun 18 20:54:07 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. 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.
>library p1;
>   SysUtils;
>procedure pas1;cdecl;
>   writeln('Hello world!');
>   Writeln('Home: ',GetEnvironmentVariable('HOME'));
>   pas1;
>   writeln('Lib started!');
>int main()
>   pas1();


More information about the fpc-devel mailing list