WiSaGaN
WiSaGaN

Reputation: 48127

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?

Upvotes: 6

Views: 8440

Answers (1)

chmeee
chmeee

Reputation: 3638

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.

Upvotes: 2

Related Questions