---
name: "intro"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/intro/3"
---

# intro(3)

introduction to the C libraries

## 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*

  (**-l***bluetooth*) The bluetooth library. See [bluetooth(3)](/bluetooth/3.md).

- *libc*

  (**-l***c*) Standard C library functions. When using the C compiler [cc(1)](/cc/1.md), it is not necessary to supply the loader flag **-l***c* for these functions. There are several \`libraries' or groups of functions included inside of *libc*:

  - standard I/O routines

    see [stdio(3)](/stdio/3.md)

  - database routines

    see [db(3)](/db/3.md)

  - bit string operators

    see [bitstring(3)](/bitstring/3.md)

  - bit and byte utilities

    see [stdbit(3)](/stdbit/3.md)

  - string operators

    see [string(3)](/string/3.md) and [bstring(3)](/bstring/3.md)

  - character tests and character operators

    see [ctype(3)](/ctype/3.md)

  - storage allocation

    see [mpool(3)](/mpool/3.md)

  - regular-expressions

    see [regex(3)](/regex/3.md)

  - remote procedure calls (RPC)

    see [rpc(3)](/rpc/3.md)

  - time functions

    see [time(3)](/time/3.md)

  - signal handling

    see [signal(3)](/signal/3.md)

- *libcalendar*

  (**-l***calendar*) The calendar arithmetic library. See [calendar(3)](/calendar/3.md).

- *libcam*

  (**-l***cam*) The common access method user library. See [cam(3)](/cam/3.md).

- *libcrypt*

  (**-l***crypt*) The crypt library. See [crypt(3)](/crypt/3.md).

- *libcurses*

  (**-l***curses* **-l***termcap*) Terminal independent screen management routines for two dimensional non-bitmap display terminals. See [ncurses(3)](/ncurses/3.md).

- *libcuse*

  (**-l***cuse*) The userland character device library. See [cuse(3)](/cuse/3.md).

- *libcompat*

  (**-l***compat*) 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*

  (**-l***devinfo*) The Device and Resource Information Utility library. See [devinfo(3)](/devinfo/3.md).

- *libdevstat*

  (**-l***devstat*) The Device Statistics library. See [devstat(3)](/devstat/3.md).

- *libdwarf*

  (**-l***dwarf*) The DWARF access library. See [dwarf(3)](/dwarf/3.md).

- *libelf*

  (**-l***elf*) The ELF access library. See [elf(3)](/elf/3.md).

- *libfetch*

  (**-l***fetch*) The file transfer library. See [fetch(3)](/fetch/3.md).

- *libgpio*

  (**-l***gpio*) The general-purpose input output library (GPIO). See [gpio(3)](/gpio/3.md).

- *libgssapi*

  (**-l***gssapi*) The generic security service application programming interface. See [gssapi(3)](/gssapi/3.md).

- *libjail*

  (**-l***jail*) The jail library. See [jail(3)](/jail/3.md).

- *libkvm*

  (**-l***kvm*) 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)](/kvm/3.md).

- *libl*

  (**-l***l*) The library for [lex(1)](/lex/1.md).

- *libm*

  (**-l***m*) The math library. See [math(3)](/math/3.md).

- *libmd*

  (**-l***md*) The message digest library. See [md4(3)](/md4/3.md), [md5(3)](/md5/3.md), [sha(3)](/sha/3.md), [sha256(3)](/sha256/3.md), [sha512(3)](/sha512/3.md), [ripemd(3)](/ripemd/3.md), [skein(3)](/skein/3.md).

- *libmp*

  (**-l***mp*)

- *libpam*

  (**-l***pam*) The pluggable authentication module library. See [pam(3)](/pam/3.md).

- *libpcap*

  (**-l***pcap*) The packet capture library. See [pcap(3)](/pcap/3.md).

- *libpmc*

  (**-l***pmc*) The performance counters library. See [pmc(3)](/pmc/3.md).

- *libpthread*

  (**-l***pthread*) The POSIX threads library. See [pthread(3)](/pthread/3.md).

- *libstdthreads*

  (**-l***stdthreads*) The ISO C11 standard ⟨threads.h⟩ library. See [thrd\_create(3)](/thrd_create/3.md).

- *libsysdecode*

  (**-l***sysdecode*) The system argument decoding library. See [sysdecode(3)](/sysdecode/3.md).

- *libtermcap*

  (**-l***termcap*) The terminal independent operation library package. See [termcap(3)](/termcap/3.md).

- *libusb*

  (**-l***usb*) The USB access library. See [usb(3)](/usb/3.md).

- *libvgl*

  (**-l***vgl*) The video graphics library. See [vgl(3)](/vgl/3.md).

- *liby*

  (**-l***y*) The library for [yacc(1)](/yacc/1.md).

- *libz*

  (**-l***z*) The general-purpose data compression library. See [zlib(3)](/zlib/3.md).

## 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 binary. This means the binary can be run even when the libraries are unavailable. However, it can be inefficient with both disk space and memory usage during execution. The C compiler, [cc(1)](/cc/1.md), 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)](/ld.so/1.md) reads these data structures and loads them into the process virtual address space. [rtld(1)](/rtld/1.md) 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 visibility, allowing multiple compilation units in a library to share things without making them available to other libraries. It is possible to load libraries dynamically via [dlopen(3)](/dlopen/3.md). The disadvantage is the added complexity that comes with loading the libraries dynamically, and the extra time taken to load the libraries. Of course, if the libraries are not available, the binary will be unable to execute. Calls across shared libraries are also slightly slower and cannot be inlined, not even with link time optimization. The C compiler, [cc(1)](/cc/1.md), can be instructed to link dynamically by specifying the **-shared** flag.

Shared libraries, as well as static libraries on architectures which produce position-independent executables (PIEs) by default, contain position-independent code (PIC). Normally, compilers produce relocatable code. Relocatable code needs to be modified at run-time, depending on where in memory it is to be run. The C compiler, [cc(1)](/cc/1.md), can be instructed to generate PIC code by specifying the **-fPIC** flag.

Static libraries are generated using the [ar(1)](/ar/1.md) utility. The libraries contain an index to the contents of the library, stored within the library itself. 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 allows routines in the library to call each other regardless of their placement within the library.

## SEE ALSO

[ar(1)](/ar/1.md), [cc(1)](/cc/1.md), [ld(1)](/ld/1.md), [nm(1)](/nm/1.md), [intro(2)](/intro/2.md), [math(3)](/math/3.md), [stdio(3)](/stdio/3.md), [make.conf(5)](/make.conf/5.md), [src.conf(5)](/src.conf/5.md)

## HISTORY

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