23 Apr 2012

gcc math.h WTF!?

#include <math.h> in gcc will not automatically pull in the math implementation only the header. To make a file with this include compile you need to add -lm on the command line (linker option). To make it a bit more convenient, in my case I had to add the option after the source file on the command line.

Example:

$ gcc -omyfile myfile.c -lm