About -lm switch used for linking math.h

Avinash Sonawane avinash.sonawane1990@gmail.com
Fri Jan 27 03:33:00 GMT 2012


Sir,
I am using gcc 4.6.1.
I have few questions regarding -lm switch. Please kindly guide me for the same.

1) Why I need to use -lm flag for math.h even if I had declared the
#include <math.h> in the code?
2) If it's all about linking the library then why I don't have to do
the same thing with stdio.h too?
3) Or we have to add the -l'library' switch for every library excluding stdio.h?
4) In case if the -l'library' switch is used for some specific
libraries only then please direct me to the complete list of such
libraries.

Thanks.

--
Avinash Sonawane
PICT Pune
India



More information about the Gcc-help mailing list