Re: to many libraries linked.



On 6/11/07, Paul Elliott <pelliott io com> wrote:
On Mon, Jun 11, 2007 at 08:57:21AM -0500, Matt Hoosier wrote:
> On 6/11/07, Paul Elliott <pelliott io com> wrote:
> >The sponsor of peless to debian complains that peless
> >links to too many libraries that it does not strictly
> >speaking need:
> >
> >g++  -g -O2   -o peless -L/usr/lib peless-peless.o peless-gmore.o
> >+peless-search.o -pthread -L/opt/gnome/lib -lgtkmm-2.4 -lgdkmm-2.4
> >-latkmm-1.6
> >+-lgtk-x11-2.0 -lpangomm-1.4 -lcairomm-1.0 -lgdk-x11-2.0 -latk-1.0
> >+-lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lfreetype -lz
> >+-lfontconfig -lexpat -lglitz -lpng12 -lXrender -lX11 -lpthread -lXau
> >-lXdmcp
> >+-lgconfmm-2.6 -lglibmm-2.4 -lgconf-2 -lgobject-2.0 -lsigc-2.0 -lORBit-2
> >-lm
> >+-lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0    -lboost_filesystem
> >-lboost_regex
> >
> >
> >gtkmm2.4 gconfmm-2.6 and boost* I have specified directly.
> >
> >the others are a result of these
> >configure.ac:
> >PKG_CHECK_MODULES(DEPS, gtkmm-2.4 >= 2.4.0 gconfmm-2.6 >= 2.6.0)
> >and this line from Makefile.am
> >peless_LDADD=$(DEPS_LIBS)  $(BOOST_FILESYSTEM_LIB) $(BOOST_REGEX_LIB)
> >Specificyly $(DEPS_LIBS).
> >
> >16 of the libraries are said to be not really needed.
>
> Can you be more specific? As I look through the list of libs specified
> on your command line, I can think of at least one spot in Gtk+ or
> gtkmm that uses every one of those. What does "not needed" mean?
>

Well if I build using CXXFLAGS='-Xlinker --as-needed'
the resulting executable works. But if I do a
objdump -p peless | grep NEEDED

both before and after adding the above option, and do a diff -c
on the results, this is what I get:

*** peless.odd  2007-06-11 11:42:42.000000000 -0500
--- aspeless.odd        2007-06-11 11:43:01.000000000 -0500
***************
*** 1,39 ****
    NEEDED      libgtkmm-2.4.so.1
-   NEEDED      libgdkmm-2.4.so.1
    NEEDED      libatkmm-1.6.so.1
-   NEEDED      libgtk-x11-2.0.so.0
    NEEDED      libpangomm-1.4.so.1
-   NEEDED      libcairomm-1.0.so.1
-   NEEDED      libgdk-x11-2.0.so.0
-   NEEDED      libatk-1.0.so.0
-   NEEDED      libgdk_pixbuf-2.0.so.0
-   NEEDED      libpangocairo-1.0.so.0
-   NEEDED      libpango-1.0.so.0
-   NEEDED      libcairo.so.2
-   NEEDED      libfreetype.so.6
-   NEEDED      libz.so.1
-   NEEDED      libfontconfig.so.1
-   NEEDED      libexpat.so.1
-   NEEDED      libglitz.so.1
-   NEEDED      libpng12.so.0
-   NEEDED      libXrender.so.1
-   NEEDED      libX11.so.6
    NEEDED      libpthread.so.0
-   NEEDED      libXau.so.6
-   NEEDED      libXdmcp.so.6
    NEEDED      libgconfmm-2.6.so.1
    NEEDED      libglibmm-2.4.so.1
-   NEEDED      libgconf-2.so.4
-   NEEDED      libgobject-2.0.so.0
    NEEDED      libsigc-2.0.so.0
-   NEEDED      libORBit-2.so.0
-   NEEDED      libgmodule-2.0.so.0
-   NEEDED      libdl.so.2
-   NEEDED      libgthread-2.0.so.0
    NEEDED      libglib-2.0.so.0
    NEEDED      libboost_filesystem.so.1.33.1
    NEEDED      libboost_regex.so.1.33.1
    NEEDED      libstdc++.so.6
-   NEEDED      libm.so.6
    NEEDED      libgcc_s.so.1
    NEEDED      libc.so.6
--- 1,13 ----

People are telling me this means that there are a lot of libraries
that peless is linking to, but is not actually using.

> >
> >It is suggested that peless add --as-needed to LDFLAGS.
> >
> >Is this a good idea? The PKG_CHECK_MODULES is the recommended
> >way to build a program using gtkmm and gconfmm.
> >
> >Suggestions Welcome.

Yes, that's probably true, but if you run 'ldd' on the executable
generated with and without the --as-needed flag, you'll probably
notice that the libraries that it loads are the same.  In the first
case, your application is pulling in all of those libraries directly.
in the second case, your application pulls in libraries that pull in
those libraries.  So the end result is that it probably doesn't make
much difference, though I don't think there's any downside to using
the --as-needed option.

--
jonner



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