Possible Duplicate:
Why do you have to link the math library in C?
I am learning C using the GCC compiler (on Linux).
I recently moved from using Code::Blocks to using Geany
, and I have noticed that Geany
doesn't automatically link to any required libraries. For example, when I would use #include <math.h>
in Code::Blocks, it would pick up on that and automatically link in the corresponding math library when I compile. However, Geany
doesn't do that and I must manually add in build commands, such as -lm
for the math library, to get the compilation to work.
However, I noticed that including the string.h
header, and using functions from it, compiled fine without linking in the string library. Why is that? Is it that the string.h
header defines all the functions itself? Could someone please explain why some libraries seem to need to be linked whereas others do not.
On a similar note, has anyone had experience in telling Geany
to automatically link in the required libraries? That would make the compiling a lot easier.