Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-06

Library linking with C explanation

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sergey Korshunoff
Show quoted text 13 lines
> Reply-To: > Date: Sun, 3 Jun 2001 15:12:42 +0200 (CEST) > From: Peter Vreman > X-Sender: > To: > 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.

Show quoted text 9 lines
> 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

Regards,
Sergey Korshunoff

Reply by email

Peter Vreman
Show quoted text 50 lines
Reply-To: Date: Sun, 3 Jun 2001 15:12:42 +0200 (CEST) From: Peter Vreman X-Sender: To: 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. p1.pp =========== library p1; uses SysUtils; procedure pas1;cdecl; begin writeln('Hello world!'); Writeln('Home: ',GetEnvironmentVariable('HOME')); end; exports pas1; begin writeln('Lib started!'); end. p.c =========== int main() { pas1(); }

Peter

Reply by email

Peter Vreman
Show quoted text 32 lines
>> Reply-To: >> Date: Sun, 3 Jun 2001 15:12:42 +0200 (CEST) >> From: Peter Vreman >> X-Sender: >> To: >> 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.

Reply by email