Re: Static linking



Tristan Van Berkom wrote:
Johannes Tanzler wrote:

On Tue, 2003-09-30 at 17:56, Russell Shaw wrote:

How do i get "pkg-config gtk+-2.0 --libs" to put out -static
instead of --export-dynamic ?

Try
 `pkg-config --libs gtk+-2.0` -static

The explicit "-static" overrides "--export-dynamic".

hmmm,
       --export-dynamic [ is an option to ld ]
       -static                   [ is a linker option to gcc ]

Usualy object files are linked according to the preceeding option passed,
i.e.:

gcc -o prog  prog.c  -shared -lone -static -ltwo

will create a program out of prog.o and libtwo.a
that links dynamicly with the object file `libone.so'

Are you sure that gcc doesn't pass `--export-dynamic' to the linker if it
finds `-static' on its command line ?

I could use some enlightenment on this subject ;-)

If i do:
  ld -o myprog -static /usr/lib/gcrt1.o main.o gui.o \
     -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 \
     -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 \
     -lc /usr/lib/gcc-lib/i386-linux/3.3.1/libgcc.a

then i get a heap of "undefined reference" linker errors from the gtk libs
because of X11 functions that are in the X libs:

  -L /usr/X11R6/lib
  -lFS -lI810XvMC -lICE -lSM -lX11 -lXTrap -lXau -lXdmcp -lXext -lXfont -lXfontcache
  -lXft -lXft1 -lXi -lXinerama -lXmu -lXmuu -lXp -lXpm -lXrandr -lXrender -lXss -lXt
  -lXtst -lXv -lXvMC -lXv_pic -lXxf86dga -lXxf86misc -lXxf86rush -lXxf86vm -lfntstubs
  -lfontenc -loldX -lxf86config -lxkbfile -lxkbui

Even if i link with the above, i still get Xlib errors probably because of
the order that the libs are searched.

If static linking is so hard to do and no one uses it, then why are there
packages such as libgtk2.0-dev on debian that have the static libraries?

dpkg -p libgtk2.0-dev
dpkg -L libgtk2.0-dev

http://lists.debian.org/debian-devel/1998/debian-devel-199808/msg00303.html
http://www.dragoninc.on.ca/mail-archives/gtk/2001-04/0015.html




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]