xref: /openbsd-src/share/man/man3/intro.3 (revision d874cce4b1d9fe6b41c9e4f2117a77d8a4a37b92)
1.\"	$OpenBSD: intro.3,v 1.36 2008/06/10 07:01:01 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: June 10 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 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 libexpat Pq Fl lexpat
158Library routines for parsing XML documents.
159.Pp
160.It libform Pq Fl lform
161Terminal-independent facilities for composing form screens on
162character-cell terminals.
163Functions using the
164.Em libform
165library must be linked with the
166.Em libcurses
167library, i.e.\&
168.Fl lform lcurses .
169See
170.Xr form 3 .
171.Pp
172.It libfrtbegin Pq Fl lfrtbegin
173.It libg2c Pq Fl lg2c
174Support routines for Fortran functions.
175These two libraries were separated to allow linking Fortran code
176with other languages on ELF platforms.
177See
178.Xr g77 1 .
179.Pp
180.It libgcc Pq Fl lgcc
181GCC runtime support,
182including long arithmetic, propolice,
183and language independent exception support.
184Note: users do not normally have to explicitly link with this library.
185.Pp
186.It libgssapi Pq Fl lgssapi
187The Generic Security Service Application Program Interface
188.Pq GSS-API
189provides security services to callers in a generic fashion.
190See
191.Xr gssapi 3 .
192.Pp
193.It libiberty Pq Fl liberty
194Collection of subroutines missing in other operating systems,
195as well as the C++ demangler and other functions used by
196the GNU toolchain.
197.Pp
198.It libkadm5clnt Pq Fl lkadm5clnt
199Kerberos administration client library,
200for talking to a Kerberos database.
201Clients communicate via the network.
202.Pp
203.It libkadm5srv Pq Fl lkadm5srv
204Kerberos administration server library,
205for talking to a Kerberos database.
206Servers talk directly to the database.
207.Pp
208.It libkeynote Pq Fl lkeynote
209System library for the keynote trust-management system.
210Trust-management systems provide standard, general-purpose mechanisms
211for specifying application security policies and credentials.
212Functions using the libkeynote library must be linked with the
213.Em libm
214and
215.Em libcrypto
216libraries, i.e.\&
217.Fl lkeynote lm lcrypto .
218See
219.Xr keynote 3
220and
221.Xr keynote 4 .
222.Pp
223.It libkrb5 Pq Fl lkrb5
224.It libasn1 Pq Fl lasn1
225.It libcom_err Pq Fl lcom_err
226.It libhdb Pq Fl lhdb
227.It libkafs Pq Fl lkafs
228Kerberos 5 libraries.
229The libraries
230.Em libasn1 ,
231.Em libcom_err ,
232.Em libhdb ,
233and
234.Em libkafs
235are all hard links to
236.Em libkrb5 .
237See
238.Xr krb5 3 .
239.Pp
240.It libkvm Pq Fl lkvm
241Kernel memory interface library.
242Provides a uniform interface for accessing kernel virtual memory images,
243including live systems and crash dumps.
244See
245.Xr kvm 3 .
246.Pp
247.It libl Pq Fl l\&l
248.It libfl Pq Fl lfl
249The library for
250.Xr lex 1 ,
251a lexical analyzer generator.
252The
253.Em libfl
254library
255is a hard link to
256.Em libl .
257.Pp
258.It libm Pq Fl lm
259Mathematical functions which comprise the C math library,
260.Em libm .
261See
262.Xr math 3 .
263.Pp
264.It libmenu Pq Fl lmenu
265Terminal-independent facilities for composing menu systems on
266character-cell terminals.
267Functions using the
268.Em libmenu
269library must be linked with the
270.Em libcurses
271library, i.e.\&
272.Fl lmenu lcurses .
273See
274.Xr menu 3 .
275.Pp
276.It libmilter Pq Fl lmilter
277The
278.Xr sendmail 8
279mail filter API.
280See the documentation in
281.Pa /usr/share/doc/html/milter/ .
282.Pp
283.It libobjc Pq Fl lobjc
284Library for Objective C, an object-oriented superset of ANSI C.
285Use this to compile Objective C programs.
286.Pp
287.It libocurses Pq Fl locurses
288.It libotermcap Pq Fl lotermcap
289Routines to provide the user with a method of updating screens
290with reasonable optimisation.
291The
292.Xr ocurses 3
293library is compatible with the
294.Em curses
295library provided in 4.3.
296.Em libotermcap
297is the 4.3-compatible
298.Em termcap
299library, and is a hard link to
300.Em libocurses .
301See
302.Xr otermcap 3 .
303.Pp
304.It libopcodes Pq Fl lopcodes
305GNU opcode library.
306.Pp
307.It libossaudio Pq Fl lossaudio
308Provides an emulation of the OSS
309.Pq Linux
310audio interface.
311This is used only for porting programs.
312See
313.Xr ossaudio 3 .
314.Pp
315.It libpanel Pq Fl lpanel
316Terminal-independent facilities for stacked windows on
317character-cell terminals.
318Functions using the
319.Em libpanel
320library must be linked with the
321.Em libcurses
322library, i.e.\&
323.Fl lpanel lcurses .
324See
325.Xr panel 3 .
326.Pp
327.It libpcap Pq Fl lpcap
328Packet capture library.
329All packets on the network, even those destined for other hosts,
330are accessible through this library.
331See
332.Xr pcap 3 .
333.Pp
334.It libperl Pq Fl lperl
335Support routines for
336.Xr perl 1 .
337.Pp
338.It libpthread Pq Fl pthread
339.St -p1003.1-2001
340threads API and thread scheduler.
341Threaded applications should use
342.Fl pthread
343not
344.Fl lpthread .
345See
346.Xr pthreads 3 .
347Note: users do not normally have to explicitly link with this library.
348.Pp
349.It libreadline Pq Fl lreadline
350Command line editing interface.
351See
352.Xr readline 3 .
353.Pp
354.It librpcsvc Pq Fl lrpcsvc
355Generated by
356.Xr rpcgen 1 ,
357containing stub functions for many common
358.Xr rpc 3
359protocols.
360.Pp
361.It libsectok Pq Fl lsectok
362Library for communicating with ISO 7816 smartcards.
363See
364.Xr sectok 3 .
365.Pp
366.It libskey Pq Fl lskey
367Support library for the S/Key one time password
368.Pq OTP
369authentication toolkit.
370See
371.Xr skey 3 .
372.Pp
373.It libssl Pq Fl lssl
374The OpenSSL ssl library implements the Secure Sockets Layer
375.Pq SSL v2/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(GCC 3.3.x 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 login 3 ,
409.Xr login_fbtab 3 ,
410.Xr opendev 3 ,
411.Xr opendisk 3 ,
412.Xr openpty 3 ,
413.Xr pidfile 3 ,
414.Xr pw_init 3 ,
415.Xr pw_lock 3 ,
416.Xr readlabelfs 3
417and
418.Xr uucplock 3 .
419.Pp
420.It libwrap Pq Fl lwrap
421TCP wrapper access control library.
422See
423.Xr hosts_access 3
424and
425.Xr rfc1413 3 .
426.Pp
427.It liby Pq Fl ly
428The library for
429.Xr yacc 1 ,
430an LALR parser generator.
431.Pp
432.It libz Pq Fl lz
433General purpose data compression library.
434The functions in this library are documented in
435.Xr compress 3 .
436The data format is described in RFCs 1950 \- 1952.
437.El
438.Pp
439Platform-specific libraries:
440.Bl -tag -width "libkvm"
441.It libalpha Pq Fl lalpha
442Alpha I/O and memory access functions.
443See
444.Xr inb 2 .
445.It libamd64 Pq Fl lamd64
446AMD64 I/O and memory access functions.
447See
448.Xr amd64_get_ioperm 2
449and
450.Xr amd64_iopl 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/libexpat.a
603.It Pa /usr/lib/libfl.a
604.It Pa /usr/lib/libform.a
605.It Pa /usr/lib/libfrtbegin.a
606.It Pa /usr/lib/libg2c.a
607.It Pa /usr/lib/gcc-lib/${ARCH}-unknown-openbsd${OSREV}/${GCCREV}/fpic/libgcc.a
608.It Pa /usr/lib/libgssapi.a
609.It Pa /usr/lib/libhdb.a
610.It Pa /usr/lib/libiberty.a
611.It Pa /usr/lib/libkadm5clnt.a
612.It Pa /usr/lib/libkadm5srv.a
613.It Pa /usr/lib/libkafs.a
614.It Pa /usr/lib/libkeynote.a
615.It Pa /usr/lib/libkrb5.a
616.It Pa /usr/lib/libkvm.a
617.It Pa /usr/lib/libl.a
618.It Pa /usr/lib/libm.a
619.It Pa /usr/lib/libmenu.a
620.It Pa /usr/lib/libmilter.a
621.It Pa /usr/lib/libncurses.a
622.It Pa /usr/lib/libobjc.a
623.It Pa /usr/lib/libocurses.a
624.It Pa /usr/lib/libopcodes.a
625.It Pa /usr/lib/libossaudio.a
626.It Pa /usr/lib/libotermcap.a
627.It Pa /usr/lib/libpanel.a
628.It Pa /usr/lib/libpcap.a
629.It Pa /usr/lib/libperl.a
630.It Pa /usr/lib/libpthread.a
631.It Pa /usr/lib/libreadline.a
632.It Pa /usr/lib/librpcsvc.a
633.It Pa /usr/lib/libsectok.a
634.It Pa /usr/lib/libskey.a
635.It Pa /usr/lib/libssl.a
636.It Pa /usr/lib/libstdc++.a
637.It Pa /usr/lib/libsupc++.a
638.It Pa /usr/lib/libtermcap.a
639.It Pa /usr/lib/libtermlib.a
640.It Pa /usr/lib/libusbhid.a
641.It Pa /usr/lib/libutil.a
642.It Pa /usr/lib/libwrap.a
643.It Pa /usr/lib/liby.a
644.It Pa /usr/lib/libz.a
645.Pp
646.It Pa /usr/lib/libalpha.a
647.It Pa /usr/lib/libamd64.a
648.It Pa /usr/lib/libarm.a
649.It Pa /usr/lib/libi386.a
650.El
651.Sh SEE ALSO
652.Xr ar 1 ,
653.Xr c++ 1 ,
654.Xr cc 1 ,
655.Xr g77 1 ,
656.Xr gcc-local 1 ,
657.Xr gprof 1 ,
658.Xr ld 1 ,
659.Xr ld.so 1 ,
660.Xr lex 1 ,
661.Xr nm 1 ,
662.Xr perl 1 ,
663.Xr ranlib 1 ,
664.Xr yacc 1 ,
665.Xr intro 2 ,
666.Xr compress 3 ,
667.Xr crypto 3 ,
668.Xr curses 3 ,
669.Xr des_crypt 3 ,
670.Xr editline 3 ,
671.Xr event 3 ,
672.Xr form 3 ,
673.Xr hosts_access 3 ,
674.Xr keynote 3 ,
675.Xr kvm 3 ,
676.Xr math 3 ,
677.Xr menu 3 ,
678.Xr ocurses 3 ,
679.Xr ossaudio 3 ,
680.Xr panel 3 ,
681.Xr pcap 3 ,
682.Xr pthreads 3 ,
683.Xr readline 3 ,
684.Xr rfc1413 3 ,
685.Xr rpc 3 ,
686.Xr sectok 3 ,
687.Xr skey 3 ,
688.Xr ssl 3 ,
689.Xr stdio 3 ,
690.Xr termcap 3 ,
691.Xr usbhid 3 ,
692.Xr keynote 4 ,
693.Xr mk.conf 5
694.Sh HISTORY
695An
696.Nm
697manual appeared in
698.At v7 .
699