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