Some strange error appeared after I upgraded my Ubuntu from (10.11, 11.04 i dont know)
to 11.10.
I am getting an undefined reference to 'sqrt'
while using math.h and linking with -lm
I'm compiling with gcc -Wall -Werror -g -Iinclude/ -lm lib/matrix.c src/analyse.c -o bin/analyse.o
both source-files use and include math.h.
This code compiled without problems for and I didn't change much since the upgrade but now it won't work.
Do you have any suggestions what I can do, to find the error?
I'm sorry, if this question was asked before; there are so many posts on math linker errors and I didn't find a matching one
The library that you are using needs to be placed after the files that use it when you are using it from the command line. So place -lm
on after your C files on the command line.