Menu

#4 Building fails when setting LDFLAGS=-Wl,--as-needed

open
nobody
None
5
2009-11-18
2009-11-18
No

Hello,

When I compile gwave with LDFLAGS=-Wl,--as-needed, the compilation fails giving this error:

gcc -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -g -O2 -Wl,-Bsymbolic-functions -Wl,--as-needed -o gwave-exec gwave-exec.o xgclient.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0
gwave-exec.o: In function `init_display':
/tmp/buildd/gwave-20090213/remote/gwave-exec.c:41: undefined reference to `XOpenDisplay'
gwave-exec.o: In function `main':
/tmp/buildd/gwave-20090213/remote/gwave-exec.c:78: undefined reference to `XFree'
/tmp/buildd/gwave-20090213/remote/gwave-exec.c:79: undefined reference to `XFree'
/tmp/buildd/gwave-20090213/remote/gwave-exec.c:80: undefined reference to `XFree'
/tmp/buildd/gwave-20090213/remote/gwave-exec.c:82: undefined reference to `XCloseDisplay'
xgclient.o: In function `xgexec_exec_full':
/tmp/buildd/gwave-20090213/remote/xgclient.c:111: undefined reference to `XSelectInput'
/tmp/buildd/gwave-20090213/remote/xgclient.c:113: undefined reference to `XChangeProperty'
/tmp/buildd/gwave-20090213/remote/xgclient.c:116: undefined reference to `XChangeProperty'
/tmp/buildd/gwave-20090213/remote/xgclient.c:120: undefined reference to `XIfEvent'
/tmp/buildd/gwave-20090213/remote/xgclient.c:142: undefined reference to `XGetWindowProperty'
/tmp/buildd/gwave-20090213/remote/xgclient.c:146: undefined reference to `XGetWindowProperty'
/tmp/buildd/gwave-20090213/remote/xgclient.c:152: undefined reference to `XGetWindowProperty'
/tmp/buildd/gwave-20090213/remote/xgclient.c:156: undefined reference to `XGetWindowProperty'
/tmp/buildd/gwave-20090213/remote/xgclient.c:162: undefined reference to `XGetWindowProperty'
xgclient.o:/tmp/buildd/gwave-20090213/remote/xgclient.c:166: more undefined references to `XGetWindowProperty' follow
xgclient.o: In function `xgexec_exec':
/tmp/buildd/gwave-20090213/remote/xgclient.c:78: undefined reference to `XFree'
/tmp/buildd/gwave-20090213/remote/xgclient.c:79: undefined reference to `XFree'
xgclient.o: In function `xgexec_init':
/tmp/buildd/gwave-20090213/remote/xgclient.c:49: undefined reference to `XInternAtom'
/tmp/buildd/gwave-20090213/remote/xgclient.c:50: undefined reference to `XInternAtom'
/tmp/buildd/gwave-20090213/remote/xgclient.c:51: undefined reference to `XInternAtom'
/tmp/buildd/gwave-20090213/remote/xgclient.c:52: undefined reference to `XInternAtom'
/tmp/buildd/gwave-20090213/remote/xgclient.c:53: undefined reference to `XInternAtom'
xgclient.o:/tmp/buildd/gwave-20090213/remote/xgclient.c:54: more undefined references to `XInternAtom' follow
xgclient.o: In function `xgexec_init':
/tmp/buildd/gwave-20090213/remote/xgclient.c:63: undefined reference to `XGetWindowProperty'
/tmp/buildd/gwave-20090213/remote/xgclient.c:65: undefined reference to `XFree'
/tmp/buildd/gwave-20090213/remote/xgclient.c:70: undefined reference to `XFree'
/tmp/buildd/gwave-20090213/remote/xgclient.c:71: undefined reference to `XCreateSimpleWindow'
collect2: ld returned 1 exit status
make[3]: *** [gwave-exec] Error 1
make[3]: Leaving directory `/tmp/buildd/gwave-20090213/remote'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/tmp/buildd/gwave-20090213'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/tmp/buildd/gwave-20090213'
dh_auto_build: make returned exit code 2
make: *** [build] Error 1

The reason I use -Wl,--as-needed is that 'dpkg-shlibdeps' (a Debian tool that calculates shared library dependencies for executables) reports that gwave executables are needlessly linked against some libraries as follows:

dpkg-shlibdeps: warning: dependency on libgwrap-core-runtime.so.2 could be avoided if "debian/gwave/usr/bin/gwave" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libgmp.so.3 could be avoided if "debian/gwave/usr/bin/gwave" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libltdl.so.7 could be avoided if "debian/gwave/usr/bin/gwave" were not uselessly linked against it (they use none of its
symbols).
dpkg-shlibdeps: warning: dependency on libncurses.so.5 could be avoided if "debian/gwave/usr/bin/gwaverepl" were not uselessly linked against it (they use none
of its symbols).
dpkg-shlibdeps: warning: dependency on libfontconfig.so.1 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libatk-1.0.so.0 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libcrypt.so.1 could be avoided if "debian/gwave/usr/bin/gwave" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libgio-2.0.so.0 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libgdk_pixbuf-2.0.so.0 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libgmodule-2.0.so.0 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libcairo.so.2 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libpango-1.0.so.0 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libgwrap-guile-runtime.so.2 could be avoided if "debian/gwave/usr/bin/gwave" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libguile-cairo.so.0 could be avoided if "debian/gwave/usr/bin/gwave" were not uselessly linked against it (they use none
of its symbols).
dpkg-shlibdeps: warning: dependency on libpangocairo-1.0.so.0 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libfreetype.so.6 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).
dpkg-shlibdeps: warning: dependency on libpangoft2-1.0.so.0 could be avoided if "debian/gwave/usr/bin/gwave debian/gwave/usr/bin/gwaverepl debian/gwave/usr/bin/sp2sp debian/gwave/usr/bin/gwave-exec" were not uselessly linked against it (they use none of its symbols).

Discussion

  • Ahmed El-Mahmoudy

    Patch to fix the build failure

     
  • Ahmed El-Mahmoudy

    The problem turned out to be that -lX11 needed to be added when linking gwave, gwave-exec & gwaverepl. I've attached a patch fixing this.

    I've actually patched Makefile.in files, probably the right course of action is to patch Makefile.am.

     

Log in to post a comment.