xref: /openbsd-src/share/man/man7/library-specs.7 (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1.\" $OpenBSD: library-specs.7,v 1.13 2018/07/09 15:34:10 jmc Exp $
2.\"
3.\" Copyright (c) 2001-2010 Marc Espie
4.\"
5.\" 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.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.Dd $Mdocdate: July 9 2018 $
28.Dt LIBRARY-SPECS 7
29.Os
30.Sh NAME
31.Nm library-specs
32.Nd shared library name specifications
33.Sh DESCRIPTION
34Each
35.Ev WANTLIB
36item in the ports tree conforms to
37.Bd -literal -offset indent
38[path/]libname[=major[.minor]]
39.Ed
40.Pp
41or
42.Bd -literal -offset indent
43[path/]libname[>=major[.minor]]
44.Ed
45.Pp
46All libraries that a package needs must be mentioned in that list.
47Except for system and X11 libraries, they all must be reachable through
48.Ev LIB_DEPENDS
49and
50.Ev RUN_DEPENDS ,
51directly, or indirectly through recursive dependencies.
52.Pp
53Conversely, the ports tree
54uses
55.Ev WANTLIB
56to check whether a given
57.Ev LIB_DEPENDS
58will be required at runtime for shared libraries, and thus turn it into a
59.Cm @depend
60line
61.Po
62see
63.Xr pkg_create 1
64.Pc .
65.Pp
66The package system will embed correct dependency checks in the built
67package in the form of
68.Cm @wantlib
69lines, according to the normal shared library semantics: any library with
70the same major number, and a greater or equal minor number will do.
71.Pp
72Note that static libraries can only satisfy a library specification if
73no shared library has been found.
74Thus, if WANTLIB = foo>=5, and both libfoo.so.4.0 and libfoo.a are present,
75the check will fail.
76.Pp
77Therefore, porters must strive to respect correct shared library semantics
78in their own ports: by bumping the minor number each time the interface is
79augmented, and by bumping the major number each time the interface changes.
80Note that adding functions to a library is an interface augmentation.
81Removing functions is an interface change.
82.Pp
83The major.minor components of the library specification are used only as a
84build-time check, the run-time checks are computed by
85.Xr port-resolve-lib-helper 1 .
86For
87.Sq libname>=major[.minor] ,
88any library which is more recent than the given major.minor version will
89do.
90If a specific major number is needed, use the form
91.Sq libname=major[.minor] .
92If the minor component is left empty, any minor will do.
93If both components are left empty, any version will do.
94.Pp
95Most specifications won't mention a
96.Pa path :
97.Xr port-resolve-lib-helper 1
98will look in the default
99.Xr ldconfig 8
100path automatically, namely
101.Pa /usr/local/lib ,
102.Pa /usr/X11R6/lib ,
103.Pa /usr/lib .
104It is generally a bad idea to put libraries elsewhere as they won't be
105reached directly.
106.Pp
107However, distinct ports may install different major versions of the same
108library in
109.Pa /usr/local/lib ,
110and disambiguate the build by creating a link in a separate directory,
111and specifying the right options to the linker.
112.Pp
113These libraries will require a
114.Pa path
115component in the corresponding
116.Ev WANTLIB
117to make sure the right library is resolved.
118This path is rooted under
119.Pa /usr/local .
120For instance, to refer to
121.Pa /usr/local/lib/qt3/libqt-mt.so.33.0 ,
122one would use
123.Sq lib/qt3/qt-mt>=33 .
124.Sh SEE ALSO
125.Xr check-lib-depends 1 ,
126.Xr ld 1 ,
127.Xr ld.so 1 ,
128.Xr pkg_add 1 ,
129.Xr port-resolve-lib-helper 1 ,
130.Xr bsd.port.mk 5 ,
131.Xr packages 7 ,
132.Xr packages-specs 7 ,
133.Xr ports 7 ,
134.Xr ldconfig 8
135.Sh HISTORY
136Full support for library specifications first appeared in
137.Ox 3.1 .
138The format of specifications changed slightly to include
139.Sq >=
140before
141.Ox 4.0 .
142The interactions between
143.Ev LIB_DEPENDS
144and
145.Ev WANTLIB
146were modified and clarified for
147.Ox 4.8 .
148The format of specifications changed again before
149.Ox 4.9
150to remove extra noise.
151