I’m new to C/C++ and I have this simple question. I don’t know when I have to link libraries when I enter the command for the compilation. If I am right I’d add the parameter -l followed by the name of the library I want to include. But if I’m working for example with the math library of C, do I have add something like -lmath to compile my program? Or is it only necessary when you are using C external libraries as I read somewhere? What are C external libraries? Could anyone explain me this? thank you.
Share
Most compilers will include the languages’ standard libraries by default when linking. gcc will include the C standard library (libc), and g++ will add the c++ standard library (libc++). On some systems you may find yourself adding
-lmfor math, or-lrtfor real-time extensions, but those libraries often add features outside the core language (though sometimes very commonly used features).