Hey Everyone -
I have a pretty simple question here that I hope to promote maybe some discussion with. I have been working with threads in an Operating Systems course, and in order to use posix threads with gcc, you need to use the -lpthread option with gcc. Now, since my instructor informed us of this beforehand, it was no big deal. However, I went to construct a program using the function sqrt(), from math.h. I included the header file, and yet I was getting linking errors. After about a half hour of research, I found that I didn't use the gcc -lm option.
Herein lies my question -
How does one know that one needs to use a dynamic library such as this? And once one knows, do you just have to memorize what library to use? I see this as somewhat of an ambiguity because in the Kernighan & Ritchie book (The C Programming Language, 2nd Ed.) they don't say anything about having to specify a library on the command line.
Thanks for any help you might be able to give,