When using gcc
under Linux, one does not need to add command-line options to use standard library functions like printf
. In book An Introduction to GCC, it explains "The C standard library itself is stored in ‘/usr/lib/libc.a’ and contains functions specified in the
ANSI/ISO C standard, such as ‘printf’—this library is linked by default for every C program."
But one has to add -lm
in the command-line to use standard library functions declared in math.h
, since libm.a
is not linked against in default.
So which standard library functions are included in libc.a
, thus do not require to link other library files. And other than libm.a
, are there any other standard library functions that need to explicitly add library files to link against, and what are the file names of the library?
libc
and libm
both handle all ANSI/ISO functions. Beyond that, Linux and UNIX systems follow POSIX, which includes libpthread
(usually linked in using the -pthread
option, not explicitly linking in the library), as well as libiconv
which may be included in libc
. Additional libraries in POSIX include curses
and libutil
for miscellaneous functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With