# Ubuntu – How to compile a C program that uses math.h

ccompilinggcc

I am having problems in math.h header file and when I use square root function as in sqrt(d). But my compiler is not supporting this. Please advise me about this problem.

My Ubuntu version is 2012.

Append -lm to the end of your gcc command.
If you are compiling on the command-line with the gcc or g++ command, you would accomplish this by putting -lm at the end of the command.
For example: gcc -o foo foo.c -lm