xref: /openbsd/share/man/man3/intro.3 (revision 91f110e0)
1.\"	$OpenBSD: intro.3,v 1.61 2013/12/05 07:45:46 jmc Exp $
2.\"	$NetBSD: intro.3,v 1.5 1995/05/10 22:46:24 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)intro.3	8.1 (Berkeley) 6/5/93
32.\"
33.Dd $Mdocdate: December 5 2013 $
34.Dt INTRO 3
35.Os
36.Sh NAME
37.Nm intro
38.Nd introduction to the C libraries
39.Sh SYNOPSIS
40.Nm cc
41.Op Ar flags
42.Ar
43.Op Fl llibrary
44.Sh DESCRIPTION
45The manual pages in section 3 provide an overview of the C library
46functions, their error returns, and other common definitions and concepts.
47Most of these functions are available from the C library,
48.Em libc .
49Other libraries, such as the math library,
50.Em libm ,
51must be indicated at compile time with the
52.Fl l
53option of the compiler.
54.Pp
55The various libraries (followed by the loader flag):
56.Pp
57.Bl -tag -width "libkvm" -compact
58.It libasn1 Pq Fl lasn1
59The abstract syntax notation (ASN) library provides routines for the
60specification of abstract data types.
61.Pp
62.It libc Pq Fl lc
63Standard C library functions.
64When using the C compiler
65.Xr cc 1 ,
66it is not necessary to supply the loader flag
67.Fl lc
68for these functions.
69There are several
70.Dq libraries
71or groups of functions included inside of libc: the standard
72.Tn I/O
73routines,
74database routines,
75bit operators,
76string operators,
77character tests and character operators,
78DES encryption routines,
79storage allocation,
80time functions,
81signal handling,
82and more.
83.Pp
84.It libcom_err Pq Fl lcom_err
85The common error description library.
86.Pp
87.It libcrypto Pq Fl lcrypto
88The OpenSSL crypto library.
89Implements a range of cryptographic algorithms,
90providing such functionality as symmetric encryption, public key cryptography,
91and certificate handling.
92See
93.Xr crypto 3 .
94.Pp
95.It libcurses Pq Fl lcurses
96.It libncurses Pq Fl lncurses
97.It libncursesw Pq Fl lncursesw
98.It libtermcap Pq Fl ltermcap
99.It libtermlib Pq Fl ltermlib
100Terminal-independent screen management routines for two-dimensional
101non-bitmap display terminals.
102This implementation is
103.Dq new curses
104and is a replacement for
105.Bx 4.2
106classic curses.
107The libraries
108.Em libncurses ,
109.Em libncursesw ,
110.Em libtermcap ,
111and
112.Em libtermlib
113are all hard links to
114.Em libcurses .
115This is for compatibility purposes only;
116new programs should link with
117.Fl lcurses .
118See
119.Xr curses 3
120and
121.Xr termcap 3 .
122.Pp
123.It libedit Pq Fl ledit
124Generic line editing and history functions, similar to those found in
125.Xr sh 1 .
126Functions using the
127.Em libedit
128library must be linked with the
129.Em libcurses
130library, i.e.\&
131.Fl ledit lcurses .
132See
133.Xr editline 3 .
134.Pp
135.It libevent Pq Fl levent
136Provides a mechanism to execute a function when a specific event on a
137file descriptor occurs or after a given time has passed.
138See
139.Xr event 3 .
140.Pp
141.It libexpat Pq Fl lexpat
142Library routines for parsing XML documents.
143.Pp
144.It libform Pq Fl lform
145.It libformw Pq Fl lformw
146Terminal-independent facilities for composing form screens on
147character-cell terminals.
148Functions using the
149.Em libform
150library must be linked with the
151.Em libcurses
152library, i.e.\&
153.Fl lform lcurses .
154.Em libformw
155is a hard link to
156.Em libform
157intended for use with
158.Em libncursesw
159wide-character functions.
160See
161.Xr form 3 .
162.Pp
163.It libfuse Pq Fl lfuse
164File system in userland library.
165See
166.Xr fuse_main 3 .
167.Pp
168.It libgcc Pq Fl lgcc
169GCC runtime support,
170including long arithmetic, propolice,
171and language independent exception support.
172Note: users do not normally have to explicitly link with this library.
173.Pp
174.It libgssapi Pq Fl lgssapi
175The Generic Security Service Application Program Interface
176.Pq GSS-API
177provides security services to callers in a generic fashion.
178See
179.Xr gssapi 3 .
180.Pp
181.It libhdb Pq Fl lhdb
182The Heimdal Kerberos 5 authentication/authorisation database access
183library.
184.Pp
185.It libiberty Pq Fl liberty
186Collection of subroutines missing in other operating systems,
187as well as the C++ demangler and other functions used by
188the GNU toolchain.
189.Pp
190.It libkadm5clnt Pq Fl lkadm5clnt
191Kerberos administration client library,
192for talking to a Kerberos database.
193Clients communicate via the network.
194.Pp
195.It libkadm5srv Pq Fl lkadm5srv
196Kerberos administration server library,
197for talking to a Kerberos database.
198Servers talk directly to the database.
199.Pp
200.It libkafs Pq Fl lkafs
201The Kerberos AFS library.
202See
203.Xr kafs 3 .
204.Pp
205.It libkeynote Pq Fl lkeynote
206System library for the keynote trust-management system.
207Trust-management systems provide standard, general-purpose mechanisms
208for specifying application security policies and credentials.
209Functions using the libkeynote library must be linked with the
210.Em libm
211and
212.Em libcrypto
213libraries, i.e.\&
214.Fl lkeynote lm lcrypto .
215See
216.Xr keynote 3
217and
218.Xr keynote 4 .
219.Pp
220.It libkrb5 Pq Fl lkrb5
221Kerberos 5 library.
222.Pp
223.It libkvm Pq Fl lkvm
224Kernel memory interface library.
225Provides a uniform interface for accessing kernel virtual memory images,
226including live systems and crash dumps.
227See
228.Xr kvm 3 .
229.Pp
230.It libl Pq Fl l\&l
231.It libfl Pq Fl lfl
232The library for
233.Xr lex 1 ,
234a lexical analyzer generator.
235The
236.Em libfl
237library
238is a hard link to
239.Em libl .
240.Pp
241.It libm Pq Fl lm
242Mathematical functions which comprise the C math library,
243.Em libm .
244.Pp
245.It libmenu Pq Fl lmenu
246.It libmenuw Pq Fl lmenuw
247Terminal-independent facilities for composing menu systems on
248character-cell terminals.
249Functions using the
250.Em libmenu
251library must be linked with the
252.Em libcurses
253library, i.e.\&
254.Fl lmenu lcurses .
255.Em libmenuw
256is a hard link to
257.Em libmenu
258intended for use with
259.Em libncursesw
260wide-character functions.
261See
262.Xr menu 3 .
263.Pp
264.It libmilter Pq Fl lmilter
265The
266.Xr sendmail 8
267mail filter API.
268See the documentation in
269.Pa /usr/share/doc/html/milter/ .
270.Pp
271.It libobjc Pq Fl lobjc
272Library for Objective C, an object-oriented superset of ANSI C.
273Use this to compile Objective C programs.
274.Pp
275.It libocurses Pq Fl locurses
276.It libotermcap Pq Fl lotermcap
277Routines to provide the user with a method of updating screens
278with reasonable optimisation.
279The
280.Xr ocurses 3
281library is compatible with the
282.Em curses
283library provided in 4.3.
284.Em libotermcap
285is the 4.3-compatible
286.Em termcap
287library, and is a hard link to
288.Em libocurses .
289See
290.Xr otermcap 3 .
291.Pp
292.It libossaudio Pq Fl lossaudio
293Provides an emulation of the OSS
294.Pq Linux
295audio interface.
296This is used only for porting programs.
297See
298.Xr ossaudio 3 .
299.Pp
300.It libpanel Pq Fl lpanel
301.It libpanelw Pq Fl lpanelw
302Terminal-independent facilities for stacked windows on
303character-cell terminals.
304Functions using the
305.Em libpanel
306library must be linked with the
307.Em libcurses
308library, i.e.\&
309.Fl lpanel lcurses .
310.Em libpanelw
311is a hard link to
312.Em libpanel
313intended for use with
314.Em libncursesw
315wide-charcter functions.
316See
317.Xr panel 3 .
318.Pp
319.It libpcap Pq Fl lpcap
320Packet capture library.
321All packets on the network, even those destined for other hosts,
322are accessible through this library.
323See
324.Xr pcap 3 .
325.Pp
326.It libperl Pq Fl lperl
327Support routines for
328.Xr perl 1 .
329.Pp
330.It libpthread Pq Fl lpthread
331.St -p1003.1-2001
332threads API.
333See
334.Xr pthreads 3 .
335.Pp
336.It libreadline Pq Fl lreadline
337Command line editing interface.
338See
339.Xr readline 3 .
340.Pp
341.It libroken Pq Fl lroken
342A library containing compatibility functions used by Kerberos.
343It implements functionality required by the Kerberos implementation not
344implemented in the standard
345.Ox
346libraries.
347.Pp
348.It librpcsvc Pq Fl lrpcsvc
349Generated by
350.Xr rpcgen 1 ,
351containing stub functions for many common
352.Xr rpc 3
353protocols.
354.Pp
355.It libskey Pq Fl lskey
356Support library for the S/Key one time password
357.Pq OTP
358authentication toolkit.
359See
360.Xr skey 3 .
361.Pp
362.It libsndio Pq Fl lsndio
363Library for
364.Xr audio 4
365hardware and the
366.Xr aucat 1
367audio server.
368See
369.Xr sio_open 3 .
370.Pp
371.It libsqlite3 Pq Fl lsqlite3
372SQL database library.
373See
374.Xr sqlite3 1 .
375.Pp
376.It libssl Pq Fl lssl
377The OpenSSL ssl library implements the Secure Sockets Layer
378.Pq SSL v3
379and Transport Layer Security
380.Pq TLS v1
381protocols.
382See
383.Xr ssl 3 .
384.Pp
385.It libstdc++ Pq Fl lstdc++
386GCC subroutine library for C++.
387See
388.Xr c++ 1 .
389Note: users do not normally have to explicitly link with this library.
390.Pp
391.It libsupc++ Pq Fl lsupc++
392C++ core language support
393(exceptions, new, typeinfo).
394Note: users do not normally have to explicitly link with this library.
395.Pp
396.It libusbhid Pq Fl lusbhid
397Routines to extract data from USB Human Interface Devices
398.Pq HIDs .
399See
400.Xr usbhid 3 .
401.Pp
402.It libutil Pq Fl lutil
403System utility functions.
404These are currently
405.Xr check_expire 3 ,
406.Xr fmt_scaled 3 ,
407.Xr fparseln 3 ,
408.Xr getmaxpartitions 3 ,
409.Xr getrawpartition 3 ,
410.Xr imsg_init 3 ,
411.Xr login 3 ,
412.Xr login_fbtab 3 ,
413.Xr opendev 3 ,
414.Xr opendisk 3 ,
415.Xr openpty 3 ,
416.Xr pidfile 3 ,
417.Xr pkcs5_pbkdf2 3 ,
418.Xr pw_init 3 ,
419.Xr pw_lock 3 ,
420.Xr readlabelfs 3
421and
422.Xr uucplock 3 .
423.Pp
424.It libwind Pq Fl lwind
425Heimdal Kerberos 5 implementation of stringprep and some of its profiles.
426.Pp
427.It libwrap Pq Fl lwrap
428TCP wrapper access control library.
429See
430.Xr hosts_access 3
431and
432.Xr rfc1413 3 .
433.Pp
434.It liby Pq Fl ly
435The library for
436.Xr yacc 1 ,
437an LALR parser generator.
438.Pp
439.It libz Pq Fl lz
440General purpose data compression library.
441The functions in this library are documented in
442.Xr compress 3 .
443The data format is described in RFCs 1950 \- 1952.
444.El
445.Pp
446Platform-specific libraries:
447.Bl -tag -width "libkvm"
448.It libalpha Pq Fl lalpha
449Alpha I/O and memory access functions.
450See
451.Xr inb 2 .
452.It libamd64 Pq Fl lamd64
453AMD64 I/O and memory access functions.
454See
455.Xr amd64_iopl 2 .
456.It libarm Pq Fl larm
457ARM I/O and memory access functions.
458See
459.Xr arm_drain_writebuf 2
460and
461.Xr arm_sync_icache 2 .
462.It libi386 Pq Fl li386
463i386 I/O and memory access functions.
464See
465.Xr i386_get_ioperm 2 ,
466.Xr i386_get_ldt 2 ,
467.Xr i386_iopl 2 ,
468and
469.Xr i386_vm86 2 .
470.El
471.Sh LIBRARY TYPES
472The system libraries are located in
473.Pa /usr/lib .
474Typically, a library will have a number of variants:
475.Bd -unfilled -offset indent
476libc.a
477libc_p.a
478libc.so.30.1
479.Ed
480.Pp
481Libraries with an
482.Sq .a
483suffix are static.
484When a program is linked against a library, all the library code
485will be linked into the binary.
486This means the binary can be run even when the libraries are unavailable.
487However, it can be inefficient with memory usage.
488The C compiler,
489.Xr cc 1 ,
490can be instructed to link statically by specifying the
491.Fl static
492flag.
493.Pp
494Libraries with a
495.Sq _p.a
496suffix are profiling libraries.
497They contain extra information suitable for analysing programs,
498such as execution speed and call counts.
499This in turn can be interpreted by utilities such as
500.Xr gprof 1 .
501The C compiler,
502.Xr cc 1 ,
503can be instructed to generate profiling code,
504or to link with profiling libraries, by specifying the
505.Fl pg
506flag.
507.Pp
508Libraries with a
509.Sq .so.X.Y
510suffix are dynamic libraries.
511When code is compiled dynamically, the library code that the application needs
512is not linked into the binary.
513Instead, data structures are added containing information about which dynamic
514libraries to link with.
515When the binary is executed, the run-time linker
516.Xr ld.so 1
517reads these data structures, and loads them at a virtual address using the
518.Xr mmap 2
519system call.
520.Pp
521.Sq X
522represents the major number of the library, and
523.Sq Y
524represents the minor number.
525In general, a binary will be able to use a dynamic library with a differing
526minor number, but the major numbers must match.
527In the example above, a binary linked with minor number
528.Sq 3
529would be linkable against libc.so.30.1,
530while a binary linked with major number
531.Sq 31
532would not.
533.Pp
534The advantages of dynamic libraries are that multiple instances of the same
535program can share address space, and the physical size of the binary is
536smaller.
537The disadvantage is the added complexity that comes with loading the
538libraries dynamically, and the extra time taken to load the libraries.
539Of course, if the libraries are not available, the binary will be unable
540to execute.
541The C compiler,
542.Xr cc 1 ,
543can be instructed to link dynamically by specifying the
544.Fl shared
545flag, although on systems that support it, this will be the default and
546need not be specified.
547.Pp
548Shared libraries, as well as static libraries on architectures which produce
549position-independent executables
550.Pq PIEs
551by default, contain position-independent code
552.Pq PIC .
553Normally, compilers produce relocatable code.
554Relocatable code needs to be modified at run-time, depending on where in
555memory it is to be run.
556PIC code does not need to be modified at run-time, but is less efficient than
557relocatable code.
558The C compiler,
559.Xr cc 1 ,
560can be instructed to generate PIC code by specifying the
561.Fl fpic
562or
563.Fl fPIC
564flags.
565.Pp
566With the exception of dynamic libraries, libraries are generated using the
567.Xr ar 1
568utility.
569The libraries contain an index to the contents of the library,
570stored within the library itself.
571The index lists each symbol defined by a member of a library that is a
572relocatable object file.
573This speeds up linking to the library, and allows routines in the library
574to call each other regardless of their placement within the library.
575The index is created by
576.Xr ranlib 1
577and can be viewed using
578.Xr nm 1 .
579.Pp
580The building of dynamic libraries can be prevented by setting the variable
581.Dv NOPIC
582in
583.Pa /etc/mk.conf .
584The building of profiling versions of libraries can
585be prevented by setting the variable
586.Dv NOPROFILE
587in
588.Pa /etc/mk.conf .
589See
590.Xr mk.conf 5
591for more details.
592.Sh SEE ALSO
593.Xr ar 1 ,
594.Xr cc 1 ,
595.Xr gcc-local 1 ,
596.Xr gprof 1 ,
597.Xr ld 1 ,
598.Xr ld.so 1 ,
599.Xr nm 1 ,
600.Xr ranlib 1 ,
601.Xr mk.conf 5
602.Sh HISTORY
603An
604.Nm
605manual appeared in
606.At v7 .
607