Louis I. answered 05/21/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
Well, the math library (usually /usr/lib/libm.a) is not the only library that requires explicit linking at the cc/gcc command line ... for example, using anything defined in curses.h would require using -lcurses as part of your gcc command line.
All C/C++ compilers include certain library bindings by default - so we don't need to.
That's one reason why even the most simple C program that does absolutely nothing ....
int main( ) {
return 0;
}
... produces a ~150K executable
-rw-rw-r--+ 1 lji None 29 May 21 08:03 nothing.c
-rwxrwxr-x+ 1 lji None 148486 May 21 08:03 nothing.exe
But the compilers can't implicitly include everything ... only the libraries that just about all programs require.
This usually managed in a makefie anyway ... where a LIBS macro might be defined and used as follows:
LIBS = -lcurses -lm # ... other libs
$(CC) -o exec src1.c src2.c $(LIBS)