I just discovered that the -lm
flag is needed by gcc in order to compile a program that refers a function from the math library. I'm wondering why an explicit linking flag isn't needed when compiling programs containing other libraries such as the time library. If I write a program where the time()
function is called, it would compile with no problems even with no linking options. But a program with the math library involved just won't work without the -lm
flag.
Can anyone please explain the reason behind this behaviour? Thanks for your time.