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