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