GNOME Bugzilla – Bug 528582
0.14.3 won't build: undefined reference to 'floor'
Last modified: 2008-04-20 14:20:12 UTC
i686-pld-linux-gcc -O2 -fno-strict-aliasing -fwrapv -march=i686 -mtune=pentium4 -gdwarf-2 -g2 -Wl,--as-needed -Wl,-z -Wl,relro -Wl,-z -Wl,-combreloc -o .libs/time-test time-test.o -Wl,--export-dynamic -pthread ./.libs/libselfcheck.a ../libplanner/.libs/libplanner-1.so /usr/lib/libgnomeui-2.so -L/usr/lib /usr/lib/libgio-2.0.so /usr/lib/libgnome-keyring.so /usr/lib/libjpeg.so /usr/lib/libbonoboui-2.so /usr/lib/libSM.so /usr/lib/libICE.so /usr/lib/libgnome-2.so /usr/lib/libesd.so /usr/lib/libasound.so /usr/lib/libaudiofile.so /usr/lib/libpopt.so /usr/lib/libbonobo-2.so /usr/lib/libbonobo-activation.so /usr/lib/libORBitCosNaming-2.so /usr/lib/libglade-2.0.so /usr/lib/libgnomeprintui-2-2.so /usr/lib/libgnomeprint-2-2.so /usr/lib/libgnomecanvas-2.so /usr/lib/libgailutil.so /usr/lib/libart_lgpl_2.so /usr/lib/libgtk-x11-2.0.so /usr/lib/libgdk-x11-2.0.so /usr/lib/libatk-1.0.so /usr/lib/libgdk_pixbuf-2.0.so /usr/lib/libpangocairo-1.0.so /usr/lib/libXinerama.so /usr/lib/libXi.so /usr/lib/libXrandr.so /usr/lib/libXcursor.so /usr/lib/libXcomposite.so /usr/lib/libXext.so /usr/lib/libXdamage.so /usr/lib/libcairo.so -lpng12 /usr/lib/libxcb-render-util.so /usr/lib/libxcb-render.so /usr/lib/libXrender.so /usr/lib/libpixman-1.so /usr/lib/libpangoft2-1.0.so /usr/lib/libpango-1.0.so /usr/lib/libfontconfig.so /usr/lib/libfreetype.so /usr/lib/libexpat.so /usr/lib/libxcb-xlib.so /usr/lib/libxcb.so /usr/lib/libXfixes.so /usr/lib/libX11.so /usr/lib/libXau.so /usr/lib/libXdmcp.so /usr/lib/libgnomevfs-2.so /usr/lib/libxml2.so -lz -lm /usr/lib/libdbus-glib-1.so -lssl -lcrypto /usr/lib/libavahi-glib.so /usr/lib/libavahi-client.so /usr/lib/libdbus-1.so /usr/lib/libavahi-common.so /usr/lib/libssp.so -lresolv -lutil /usr/lib/libgconf-2.so /usr/lib/libORBit-2.so /usr/lib/libgmodule-2.0.so -ldl /usr/lib/libgthread-2.0.so -lpthread -lrt /usr/lib/libgobject-2.0.so -lselinux /usr/lib/libglib-2.0.so /usr/lib/libpcre.so ../libplanner/.libs/libplanner-1.so: undefined reference to `floor'
Can you provide the output of the following three commands? In the last command replace N.M with whatever version that libm file has. ldd ../libplanner/.libs/libplanner-1.so nm ../libplanner/.libs/libplanner-1.so |grep floor nm /lib/libm-N.M.so |grep floor
[patrys@meaw planner-0.14.3]$ ldd libplanner/.libs/libplanner-1.so linux-gate.so.1 => (0xb7f94000) libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0xb7f48000) libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0xb7f10000) libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb7e66000) libpthread.so.0 => /lib/libpthread.so.0 (0xb7e4f000) libc.so.6 => /lib/libc.so.6 (0xb7d16000) libdl.so.2 => /lib/libdl.so.2 (0xb7d12000) libpcre.so.0 => /lib/libpcre.so.0 (0xb7ceb000) /lib/ld-linux.so.2 (0x80000000) [patrys@meaw planner-0.14.3]$ nm libplanner/.libs/libplanner-1.so | grep floor U floor [patrys@meaw planner-0.14.3]$ nm /lib/libm-2.7.so | grep floor nm: /lib/libm-2.7.so: no symbols Please note the --as-needed parameter we use to remove unneeded dependencies. It might happen that you forgot to specify some library and without --as-needed it gets pulled by another lib (here stripped by --as-needed).
Can you also give me the commands you used to build planner? So far I've been unable to reproduce this problem.
+ cd planner-0.14.3 + cp -f /usr/share/automake/config.sub . + glib-gettextize --copy --force + intltoolize --copy --force + libtoolize --copy --force + aclocal + autoconf + automake -a -c -f --foreign + ./configure \ LDFLAGS="-Wl,--as-needed -Wl,-z,relro -Wl,-z,-combreloc" \ CFLAGS="-O2 -fno-strict-aliasing -fwrapv -march=i686 -mtune=pentium4 -gdwarf-2 -g2" \ CXXFLAGS="-O2 -fno-strict-aliasing -fwrapv -march=i686 -mtune=pentium4 -gdwarf-2 -g2" \ FFLAGS="-O2 -fno-strict-aliasing -fwrapv -march=i686 -mtune=pentium4 -gdwarf-2 -g2" \ FCFLAGS="-O2 -fno-strict-aliasing -fwrapv -march=i686 -mtune=pentium4 -gdwarf-2 -g2" \ CPPFLAGS= \ CC=i686-pld-linux-gcc \ CXX=i686-pld-linux-g++ \ --host=i686-pld-linux \ --build=i686-pld-linux \ --prefix=/usr \ --exec-prefix=/usr \ --bindir=/usr/bin \ --sbindir=/usr/sbin \ --sysconfdir=/etc \ --datadir=/usr/share \ --includedir=/usr/include \ --libdir=/usr/lib \ --libexecdir=/usr/lib \ --localstatedir=/var \ --sharedstatedir=/var/lib \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --x-libraries=/usr/lib \ --disable-update-mimedb \ --enable-eds \ --enable-database \ --enable-gtk-doc \ --enable-python \ --enable-python-plugin \ --enable-timetable
Created attachment 109543 [details] [review] fix build with --as-needed This patch adds to libplanner_1_la_LIBADD missing library (in this case libm), so linking won't fail anymore.
I am still unable to reproduce this problem on Gentoo, but I've committed the suggested change. If you have any idea why you are seeing this problem and I'm not, please send me or the planner-dev list a mail. The fix will be available in the next major software release. Thank you for your bug report.
I am not sure if you are familiar with gcc4's --as-needed switch. Sorry if you know all this: --as-needed causes the linker to check each linked library for symbols used in the object files. If there are none then the library is dropped and the resulting binary does not link to it. This is very useful as most projects specify only one set of libraries for all the binaries they produce. This results in uneeded dependencies in some of them. On the other hand when a project forgets to specify all the direct dependencies it can happen that without --as-needed one of the linked libraries accidentally pulls all the missing deps and linking works fine (in your case some other library pulls the libm dependency while it should not). After recompiling the library with --as-needed the libm dependency will go away and planner fails to link with unresolved symbols. In any case if a project uses symbols from a particular library it should explicitly link against it, not depending on some other library pulling the necessary dependencies and this is what the above patch does.