Recent

Author Topic: shared library statically linked  (Read 488 times)

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
shared library statically linked
« on: January 19, 2023, 12:03:23 pm »
Hello,
I have a lpi that produces a .so (say acertain.so)  that works.

Currently if I do

Code: Pascal  [Select][+][-]
  1. file acertain.so
  2. acertain.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
  3.  

I would like it to be statically linked, so I modify lpi to include -Xt -XS, but result is still

Code: Pascal  [Select][+][-]
  1. file acertain.so
  2. acertain.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
  3.  

Is it possible to obtain statically linked for a .so like it happens for executables? In example below I give to compilet -Xt -XS and is does the job for a standard linux program.

Code: Bash  [Select][+][-]
  1. user_tt@development:~/tmp/test-static-linking$ file project1
  2. project1: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, with debug_info, not stripped
  3.  

Thanks
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11445
  • FPC developer.
Re: shared library statically linked
« Reply #1 on: January 19, 2023, 12:05:30 pm »
What does ldd   <the .so>  say ?

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: shared library statically linked
« Reply #2 on: January 19, 2023, 12:08:29 pm »
What does ldd   <the .so>  say ?

Code: Bash  [Select][+][-]
  1. user_tt@development:~$ ldd fpc-build/bin/x86_64-linux/libXXXXXXXXXX-x86_64-linux.so
  2.         /lib64/ld-linux-x86-64.so.2 (0x00007f9fa4725000)
  3.         linux-vdso.so.1 (0x00007ffffd926000)
  4.         libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9fa41c2000)
  5.         libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9fa41bc000)
  6.         libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9fa3fe7000)
  7.  
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Чебурашка

  • Hero Member
  • *****
  • Posts: 568
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: shared library statically linked
« Reply #3 on: January 19, 2023, 12:11:00 pm »
I tried creating a lpi containing the following library code:

Code: Pascal  [Select][+][-]
  1. library externalobject;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.       Classes
  7.       { you can add units after this };
  8.  
  9.  
  10. procedure sayYes(m: string);
  11. begin
  12.   Writeln(m);
  13.  
  14. end;
  15.  
  16. exports
  17.   SayYes;
  18.  
  19. begin
  20. end.
  21.  

But -Xt -XS do not result in a statically linked .so either.
« Last Edit: January 19, 2023, 12:17:49 pm by tt »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

 

TinyPortal © 2005-2018