Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
INTRO(3)		     Library Functions Manual			INTRO(3)

NAME
     intro -- introduction to the C libraries

SYNOPSIS
     cc [flags] file ... [-llibrary]

DESCRIPTION
     This  section  provides an overview of the C library functions, their error
     returns and other common definitions and concepts.  Most of these functions
     are available from the C library, libc.  Other libraries, such as the  math
     library,  libm, must be indicated at compile time with the -l option of the
     compiler.

     The various libraries (followed by the loader flag):

     libbluetooth  (-lbluetooth) The bluetooth library.  See bluetooth(3).

     libc	   (-lc) Standard C library functions.	When using  the  C  com-
		   piler  cc(1),  it  is not necessary to supply the loader flag
		   -lc for these functions.  There are	several  `libraries'  or
		   groups of functions included inside of libc:

		   standard I/O routines
			   see stdio(3)

		   database routines
			   see db(3)

		   bit string operators
			   see bitstring(3)

		   bit and byte utilities
			   see stdbit(3)

		   string operators
			   see string(3) and bstring(3)

		   character tests and character operators
			   see ctype(3)

		   storage allocation
			   see mpool(3)

		   regular-expressions
			   see regex(3)

		   remote procedure calls (RPC)
			   see rpc(3)

		   time functions
			   see time(3)

		   signal handling
			   see signal(3)

     libcalendar   (-lcalendar)  The  calendar	arithmetic  library.  See calen-
		   dar(3).

     libcam	   (-lcam) The common access method user library.  See cam(3).

     libcrypt	   (-lcrypt) The crypt library.  See crypt(3).

     libcurses	   (-lcurses -ltermcap) Terminal independent  screen  management
		   routines  for  two  dimensional non-bitmap display terminals.
		   See ncurses(3).

     libcuse	   (-lcuse) The userland character device library.  See cuse(3).

     libcompat	   (-lcompat) Functions which are obsolete but are available for
		   compatibility with 4.3BSD.  In particular, a number of system
		   call interfaces provided in previous  releases  of  BSD  have
		   been  included  for	source code compatibility.  Use of these
		   routines should, for the most part, be avoided.   The  manual
		   page  entry	for  each  compatibility  routine  indicates the
		   proper interface to use.

     libdevinfo    (-ldevinfo) The Device and Resource Information  Utility  li-
		   brary.  See devinfo(3).

     libdevstat    (-ldevstat) The Device Statistics library.  See devstat(3).

     libdwarf	   (-ldwarf) The DWARF access library.	See dwarf(3).

     libelf	   (-lelf) The ELF access library.  See elf(3).

     libfetch	   (-lfetch) The file transfer library.  See fetch(3).

     libfigpar	   (-lfigpar)  The configuration file parsing library.	See fig-
		   par(3).

     libgpio	   (-lgpio) The general-purpose  input	output	library  (GPIO).
		   See gpio(3).

     libgssapi	   (-lgssapi)  The generic security service application program-
		   ming interface.  See gssapi(3).

     libjail	   (-ljail) The jail library.  See jail(3).

     libkvm	   (-lkvm) Functions used to access kernel memory  are	in  this
		   library.   They can be used against both a running system and
		   a crash dump.  See kvm(3).

     libl	   (-ll) The library for lex(1).

     libm	   (-lm) The math library.  See math(3).

     libmd	   (-lmd) The  message	digest	library.   See	md4(3),  md5(3),
		   sha(3), sha256(3), sha512(3), ripemd(3), skein(3).

     libmp	   (-lmp)

     libpam	   (-lpam)  The  pluggable  authentication  module library.  See
		   pam(3).

     libpcap	   (-lpcap) The packet capture library.  See pcap(3).

     libpmc	   (-lpmc) The performance counters library.  See pmc(3).

     libpthread    (-lpthread) The POSIX threads library.  See pthread(3).

     libstdthreads
		   (-lstdthreads) The ISO C11 standard <threads.h> library.  See
		   thrd_create(3).

     libsysdecode  (-lsysdecode) The system argument decoding library.	See sys-
		   decode(3).

     libtermcap    (-ltermcap) The terminal independent operation library  pack-
		   age.  See termcap(3).

     libusb	   (-lusb) The USB access library.  See usb(3).

     libvgl	   (-lvgl) The video graphics library.	See vgl(3).

     liby	   (-ly) The library for yacc(1).

     libz	   (-lz)  The  general-purpose	data  compression  library.  See
		   zlib(3).

FILES
     /usr/lib/libc.a	the C library
     /usr/lib/libm.a	the math library

LIBRARY TYPES
     The system libraries are located in /lib and /usr/lib.  A library	has  the
     following naming convention:

	   libc.so.7

     Libraries with an `.a' suffix are static.	When a program is linked against
     a	static	library,  all necessary library code will be included in the bi-
     nary.  This means the binary can be run even when	the  libraries	are  un-
     available.   However, it can be inefficient with both disk space and memory
     usage during execution.  The C compiler, cc(1), can be instructed	to  link
     statically by specifying the -static flag.

     Libraries with a `.so.X' suffix are dynamic libraries.  When code is linked
     dynamically, the library code that the application needs is not included in
     the  binary.   Instead,  data  structures	are added containing information
     about which dynamic libraries to link with.  When the binary  is  executed,
     the  run-time  linker  ld.so(1)  reads these data structures and loads them
     into the process virtual address space.  rtld(1) loads the shared libraries
     when the program is executed.

     `X' represents the library version number of the library.	In  the  example
     above, a binary linked with libc.so.8 would not be usable on a system where
     only libc.so.7 is available.

     The advantages of dynamic libraries are that multiple instances of the same
     library  can  share  address  space, and the physical size of the binary is
     smaller.  A namespace per shared library is available via	hidden	visibil-
     ity, allowing multiple compilation units in a library to share things with-
     out  making  them available to other libraries.  It is possible to load li-
     braries dynamically via dlopen(3).  The disadvantage is the added	complex-
     ity  that	comes with loading the libraries dynamically, and the extra time
     taken to load the libraries.  Of course, if the libraries	are  not  avail-
     able,  the binary will be unable to execute.  Calls across shared libraries
     are also slightly slower and cannot be inlined, not even with link time op-
     timization.  The C compiler, cc(1), can be instructed to  link  dynamically
     by specifying the -shared flag.

     Shared  libraries,  as well as static libraries on architectures which pro-
     duce position-independent executables (PIEs) by default, contain  position-
     independent code (PIC).  Normally, compilers produce relocatable code.  Re-
     locatable code needs to be modified at run-time, depending on where in mem-
     ory  it is to be run.  The C compiler, cc(1), can be instructed to generate
     PIC code by specifying the -fPIC flag.

     Static libraries are generated using the ar(1) utility.  The libraries con-
     tain an index to the contents of the library, stored within the library it-
     self.  The index lists each symbol defined by a member of a library that is
     a relocatable object file.  This speeds up linking to the library, and  al-
     lows  routines in the library to call each other regardless of their place-
     ment within the library.

SEE ALSO
     ar(1), cc(1), ld(1),  nm(1),  intro(2),  math(3),	stdio(3),  make.conf(5),
     src.conf(5)

HISTORY
     An intro manual appeared in Version 7 AT&T UNIX.

FreeBSD 15.1			November 10, 2025			INTRO(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=intro&sektion=3&manpath=FreeBSD+15.1-RELEASE+and+Ports.quarterly>

home | help