Calling shared libs from static libs

Russell Shaw rjshaw@iprimus.com.au
Wed Oct 1 16:26:00 GMT 2003


Andreas Schwab wrote:
> Russell Shaw <rjshaw@iprimus.com.au> writes:
> 
>>Is this a bug, or should -static apply globally?
> 
> It's not a bug.  Use -Bstatic/-Bdynamic for selective static linking.
> 
> Andreas.

"man ld" lists them together:

   -Bstatic
   -dn
   -non_shared
   -static
       Do not link against shared libraries. This is...


However, i confirmed -Bstatic works. A doc bug should be filed.


I found another bug. This works:

   gcc -o shapegen main.o gui.o xmalloc.o object.o menu.o dialog.o
       -Wl,/usr/lib/libgtk-x11-2.0.a -Bstatic
       -lgdk-x11-2.0  -latk-1.0 -lgdk_pixbuf-2.0 -lpangoxft-1.0 -lpangox-1.0
       -lpango-1.0 -lgmodule-2.0 -lglib-2.0 -lgobject-2.0
       -Bdynamic -ldl -L /usr/X11R6/lib -lXinerama -lXi -lm -lc


This should do the same as above, but it gives tons of linker errors:

   gcc -o shapegen main.o gui.o xmalloc.o object.o menu.o dialog.o
       -Wl,-Bstatic -lgtk-x11-2.0
       -lgdk-x11-2.0  -latk-1.0 -lgdk_pixbuf-2.0 -lpangoxft-1.0 -lpangox-1.0
       -lpango-1.0 -lgmodule-2.0 -lglib-2.0 -lgobject-2.0
       -Bdynamic -ldl -L /usr/X11R6/lib -lXinerama -lXi -lm -lc



More information about the Binutils mailing list