0

In the video of compiler, we have to link the math library with hello.o with with the -lm flag. Why don't we have to link stdio library with hello.o?

1

because, unlike the math library, the standard library is linked by default unless you tell the compiler that you don't want that to happen, which isn't usually what you need.

1
1

Explicitly linking of library is only needed if you are using a non-standard library in your program such as math.h and cs50.h. Standard libraries such as stdio.h, stdlib.h, string.h, ctype.h etc. are by default linked in the linking step in the compilation process. Hope this answers your question.

1
  • header files are not libraries per-se!
    – kzidane
    Dec 9 '15 at 9:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .