Page 1 of 1

Removing dependencies [fixed!]

Posted: Thu Apr 12, 2007 1:36 pm
by pbdep
Hi Fred,

How do i remove all the unused/unnessesary library dependencies
from a PB Linux binary or .so ? (during compilation)


Here is a normal X11 ldd output of a simple X11 program ->


libXm.so.2 => /usr/X11R6/lib/libXm.so.2 (0x40033000)
libc.so.6 => /lib/libc.so.6 (0x401ae000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x402dc000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x403a9000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x403b2000)
libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x403ca000)
libXp.so.6 => /usr/X11R6/lib/libXp.so.6 (0x4041c000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40425000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x40433000)
libz.so.1 => /usr/lib/libz.so.1 (0x4049d000)
/lib/ld-linux.so.2 (0x40000000)
libdl.so.2 => /lib/libdl.so.2 (0x404af000)



Here is the PB output ->

libpthread.so.0 => /lib/libpthread.so.0 (0x40033000)
libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x40087000)
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x4037a000)
libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x403fa000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x40414000)
libm.so.6 => /lib/libm.so.6 (0x4042a000)
libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0x4044d000)
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x40456000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0x40490000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x404d9000)
libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x40513000)
libdl.so.2 => /lib/libdl.so.2 (0x40517000)
libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x4051b000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x405a2000)
libc.so.6 => /lib/libc.so.6 (0x405a6000)
/lib/ld-linux.so.2 (0x40000000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x406d4000)
libXrender.so.1 => /usr/X11R6/lib/libXrender.so.1 (0x407a1000)
libXrandr.so.2 => /usr/X11R6/lib/libXrandr.so.2 (0x407aa000)
libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x407af000)
libXinerama.so.1 => /usr/X11R6/lib/libXinerama.so.1 (0x407b7000)
libfontconfig.so.1 => /usr/X11R6/lib/libfontconfig.so.1 (0x407ba000)
libXcursor.so.1 => /usr/X11R6/lib/libXcursor.so.1 (0x407e1000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x407ea000)
libXfixes.so.3 => /usr/X11R6/lib/libXfixes.so.3 (0x407f8000)
libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0x407fe000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x40824000)
libz.so.1 => /usr/lib/libz.so.1 (0x4088e000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x408a0000)
libexpat.so.0 => /usr/lib/libexpat.so.0 (0x408da000)



The problem is that PB has too many dependencies which cause direct
imcompatibility's between linux distributions.

So actualy the onces not used in the source code should be removed
during compilation. I know we had this question once befor ;-) but cant
remember the trick (If it was Win32 or Linux)

Its seems also that this only happens with GUI based and 2ddraw applications.



Regards, Norman

Posted: Thu Apr 12, 2007 6:37 pm
by Fred
How do you want to do GUI apps without using a GUI toolkit like gtk ?

Posted: Thu Apr 12, 2007 9:03 pm
by pbdep
Hi Fred,

for a simple GTK2 application i normaly only have these ->

libpthread.so.0 => /lib/libpthread.so.0 (0x40033000)
libgtk-1.2.so.0 => /usr/lib/libgtk-1.2.so.0 (0x40087000)
libgdk-1.2.so.0 => /usr/lib/libgdk-1.2.so.0 (0x401a5000)
libgmodule-1.2.so.0 => /usr/lib/libgmodule-1.2.so.0 (0x401d6000)
libgthread-1.2.so.0 => /usr/lib/libgthread-1.2.so.0 (0x401d9000)
libglib-1.2.so.0 => /usr/lib/libglib-1.2.so.0 (0x401dc000)
libdl.so.2 => /lib/libdl.so.2 (0x401fd000)
libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x40202000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x4020a000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40218000)
libm.so.6 => /lib/libm.so.6 (0x402e5000)


I dont need Xcursor Xinerama Xrandr Xrender Cairo Pango FreeType Libz png expat.. those are also not used in the application, so why are they staticly linked? Cant those be removed from the header during compilation? I thought
that was possible?

Norman.

Posted: Fri Apr 13, 2007 8:22 am
by pbdep
I fixed it.. thanks...

Posted: Fri Apr 13, 2007 10:16 am
by walker
would you tell the world WHAT you'd done :?:

Posted: Fri Apr 13, 2007 6:21 pm
by pbdep
Sure ;-)

As always, Fred is very strict in what he links in the Purebasic executable,
so anything that is actualy needed is inside, sometimes there is a little
overhead but its overall quite tidy ;-)

If you look at the Purebasic.asm output generated during compilation
you will see that the files are all strict and nice..also the .a files..
(How to do this is listed somewhere in this forum/linux back in 2003 ;-)

Anyway.. In one of the early versions of purebasic it was possible to
remove library's from the .asm file and recompile it. (ircc ;-) Thats not
needed anymore if you look at it now..

So basicly removing the dependency's is not possible because purebasic
simlpy takes the GTK/GDK libs and SDL libs and all other you used, what is
related or depending again to them is also taken with it during compilation..
So that explains the big list..

The things you can do to shorten the list is to Or remove the library's
from your system or rerun ldconfig with another config file.. Or compile
it on a system that has minimal installed because GDK uses those for
some part if you have them installed...

So to be short, if you have an Linux distribution with GTK1/2 there
is no worry on switching systems and your PB binary..

If you use a small distribution linux systems it could become a problem,
but then simply install GTK/SDL etc.. and compile your code on those and its fixed..

;-)

Posted: Fri Apr 13, 2007 6:36 pm
by Fred
The post with your gtk libs are GTK1.2. You used the standard subsystem on PB which is GTK2.0 so the comparison doesn't stand. To have a gtk1.2 executable, just use the "--subsystem gtk1" command line (tough this subsystem will be probably a bit broken as no more extensively tested/and or enhanced).