When I compiled SVM-multiclass using
make, I got an error msg saying “undefined reference to sqrt“. I check the
makefile and found that
-lm is included in the
The trick here is to put the library AFTER the module you are compiling. The problem is a reference thing. The linker resolves references in order, so when the library is BEFORE the module being compiled, the linker gets confused and does not think that any of the functions in the library are needed. By putting the library AFTER the module, the references to the library in the module are resolved by the linker.
I also found that there was
$(LIBS) at end of each commend line, so I simply added
LIBS = -lm at the beginning of the makefile. Everything works fine now.