There has been a change to the build tools in ubuntu 11.10 - The "--as-needed" flag is now passed to the linker. This primarily has implications for dynamic library linking but it also affects the order that libraries appear on the command line even for static linking.
A simple example of the problem:
frankster@frankie-laptop:~> cat testm.c #include <math.h> int main(int argc, char*argv[]){ double x; double return_val = ceil(x); return 0; } frankster@frankie-laptop:~> gcc -lm testm.c /tmp/ccNkQLo6.o: In function `main': testm.c:(.text+0x15): undefined reference to `ceil' collect2: ld returned 1 exit status>
A quick fix solution could be to pass the "-Wl,--no-as-needed" option to gcc which turns off the option in ld. However the real problem in the example I provided is the order of -lm and testm.c. The following builds successfully:
gcc testm.c -lm
More info at http://www.gentoo.org/proj/en/qa/asneeded.xml and https://wiki.ubuntu.com/OneiricOcelot/ReleaseNotes?action=show&redirect=OneiricOcelot%2FTechnicalOverview#GCC_4.6_Toolchain
7 replies on “undefined reference to `ceil' (or pow or floor or ...) in ubuntu 11.10”
Thanks!!!, it was a great help!
Really helpful
Thank you!
Thanks for this useful article 😀 It helped me build NMEA Library on my BeagleBone
Thanks a lot
I was in trouble for two days with ubuntu 11.10 and openembedded stable/2009 branch
this hint helped me to fix it by changing:
-Dldflags="${LDFLAGS}" \
To:
-Dldflags="${LDFLAGS} -Wl,--no-as-needed -lpthread -lm" \
I hope it helps someone just like this article helped me
I forget to say the change that mentioned above done in $OEBASE/openembedded/recipes/perl/perl-native_5.88.bb
Hi I would like to update the operating system for my E-MU Virtuoso 2000 which is currently version 1.24 I believe there is an update to version 2.26?
My computer : Mac Pro 12 core
Mac OSX 10.9.5
I would also want to purchase either NEW,SECOND HAND or B stock from plastic silver front panel.
Many thanks