Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What standard library function does libc.a contain?

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?

like image 486
WiSaGaN Avatar asked Nov 04 '22 18:11

WiSaGaN


1 Answers

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.

like image 135
chmeee Avatar answered Nov 10 '22 18:11

chmeee