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?
When using gcc under Linux, one does not need to add command-line options to
Share
libcandlibmboth handle all ANSI/ISO functions. Beyond that, Linux and UNIX systems follow POSIX, which includeslibpthread(usually linked in using the-pthreadoption, not explicitly linking in the library), as well aslibiconvwhich may be included inlibc. Additional libraries in POSIX includecursesandlibutilfor miscellaneous functions.