- #1
The_Doctor
- 17
- 0
Just a few questions about C.
When using #include <math.h>, why is it that when compiling in gcc, I need to add the option -lm. I understand that -l links to some libraries, but why does the compiler need to be linked to whatever 'm' links to? Why can't the compiler find math.h by itself? And what is linking in terms of compilers?
And can I make my own C libraries with my own code in it, like how custom modules can be used in python? And how would I use these custom libraries in other code? Would I just write #include <lib.h> or something? And how do I tell the compiler where to look for these custom libraries?
When using #include <math.h>, why is it that when compiling in gcc, I need to add the option -lm. I understand that -l links to some libraries, but why does the compiler need to be linked to whatever 'm' links to? Why can't the compiler find math.h by itself? And what is linking in terms of compilers?
And can I make my own C libraries with my own code in it, like how custom modules can be used in python? And how would I use these custom libraries in other code? Would I just write #include <lib.h> or something? And how do I tell the compiler where to look for these custom libraries?