Recent

Author Topic: On free pascal static dynamic linker  (Read 4545 times)

benohb

  • Full Member
  • ***
  • Posts: 213
On free pascal static dynamic linker
« on: April 02, 2018, 10:41:46 am »


I am really confused about FPC static/dynamic linker in linux .Maybe I'm wrong in understanding But I see it as illogical
According to the wiki, Free Pascal comes by default "statically linked" with libraries this makes the program no longer needs external requirements..It is understandable



http://wiki.freepascal.org/Size_Matters
Quote
FPC compiles and links a static executable by default. That means it tells the linker to put all .o files of the project and all packages into one big executable.

But why when you use the command "objdump"


Example with fpgui


Code: Pascal  [Select][+][-]
  1. objdump ./customstyles_test | grep NEEDED
  2.  
  3.  
  4.   NEEDED               libX11.so.6
  5.   NEEDED               libXft.so.2
  6.   NEEDED               libfontconfig.so.1
  7.   NEEDED               libc.so.6
  8.  


Note that still need external libraries and must be in the operating system



What's going on ??

« Last Edit: April 02, 2018, 11:30:28 am by benohb »

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: On free pascal static dynamic linker
« Reply #1 on: April 02, 2018, 11:20:36 am »
The libc I can understand but the X* stuff (that YOU wrote yourself) should not be there.... :D
Happy Easter.
« Last Edit: April 02, 2018, 11:23:06 am by Thaddy »
Specialize a type, not a var.

benohb

  • Full Member
  • ***
  • Posts: 213
Re: On free pascal static dynamic linker
« Reply #2 on: April 02, 2018, 11:29:18 am »

The strange thing is here.. with fpgui library comes a file fpg_xft_x11.pas  it is static linkerd with libxft and libfontconfig
I turned it dynamically
Code: Pascal  [Select][+][-]
  1. xfthlib:=LoadLibrary('/usr/lib/XXX-linux-gnu/libXft.so.2');
  2. pointer(XftDrawCreate):=GetProcAddress(xfthlib,'XftDrawCreate');
  3. ...............
  4. ..
  5. pointer(FcFontSetDestroy):=GetProcAddress(xfthlib,'FcFontSetDestroy'); //<------Note here
  6.  
The program runs without errors ..This is proof that libxft load libfontconfig Automatically
I think the executable in Linux has become static/dynamic at the same time it makes the static linker without its Advantages

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: On free pascal static dynamic linker
« Reply #3 on: April 02, 2018, 11:42:59 am »
That Is strange... Nice Easter puzzle...
Specialize a type, not a var.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: On free pascal static dynamic linker
« Reply #4 on: April 02, 2018, 11:43:52 am »
You misunderstood the range of linking. all code that is compiled by the FPC compiler is statically linked there is no dynamic link (yet?). FPGUI and lcl do not provide obj files for system libraries and choose to bind with them directly either statically or dynamically. A static bind is one that uses the extern type of linking and a dynamic binding is the one that use loadlibrary, getprocaddress etc procedures to bind to the libraries at runtime. Both are referred to as static/dynamic linking but they are different processes that is why I prefer to call the process of attaching to external libraries as binding instead of linking although the linker is responsible on both cases.

So in short if the code is not compile by fpc then its probably a bind usually a static bind becoming.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: On free pascal static dynamic linker
« Reply #5 on: April 02, 2018, 12:02:54 pm »
taazz: he wrote the bindings... you are probably using them every day. It is a puzzle... ;D
Specialize a type, not a var.

benohb

  • Full Member
  • ***
  • Posts: 213
Re: On free pascal static dynamic linker
« Reply #6 on: April 02, 2018, 12:07:24 pm »
taazz ..Thank you

 

TinyPortal © 2005-2018