Q:

undefined reference issue in math.h

I have include the math.h in my c file, however it keeps prompts undefined reference to truncand  undefined reference to ceil.  And I didn't even use trunc in my file.  Could anyone tell what was the problem? 

A:

If you compile using gcc, you might need to add -lm option to link to the math library (libm) like
gcc test.c -lm

