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