@@ -11,14 +11,16 @@ Installing Prebuilt MongoDB C Driver Libraries
11
11
.. _Homebrew : https://brew.sh/
12
12
13
13
The |libmongoc | and |libbson | libraries are often available in the package
14
- management repositories of `common Linux distributions <linux _>`_ and
15
- `macOS via Homebrew <macos _>`_.
14
+ management repositories of `common Linux distributions <installing. linux _>`_ and
15
+ `macOS via Homebrew <installing. macos _>`_.
16
16
17
17
.. note ::
18
18
19
- For Windows, it is recommended to instead
19
+ For :index: ` Windows ` , it is recommended to instead
20
20
:doc: `build the libraries from source <from-source >`, for maximum
21
- compatibility with the local toolchain.
21
+ compatibility with the local toolchain. Building from source can be automated
22
+ by using a from-source library package management tool such as Conan _ or
23
+ vcpkg _ (See: :ref: `installing.pkgman `).
22
24
23
25
.. caution ::
24
26
@@ -30,8 +32,110 @@ management repositories of `common Linux distributions <linux_>`_ and
30
32
For the most up-to-date versions of the C driver libraries, prefer to instead
31
33
:doc: `build from source <from-source >`.
32
34
35
+ .. seealso ::
33
36
34
- .. _linux :
37
+ For a listing and common reference on available packages, refer to
38
+ :doc: `/ref/packages `.
39
+
40
+
41
+ .. index ::
42
+ package managers; Conan
43
+ package managers; vcpkg
44
+ pair: installation; package managers
45
+ :name: installing.pkgman
46
+
47
+ Cross Platform Installs Using Library Package Managers
48
+ ******************************************************
49
+
50
+ Various library package managers offer |libbson | and |libmongoc | as installable
51
+ packages, including Conan _ and vcpkg _. This section will detail how to install
52
+ using those tools.
53
+
54
+ .. _conan : https://conan.io/
55
+ .. _vcpkg : https://vcpkg.io/
56
+
57
+
58
+ .. index ::
59
+ ! pair: installation; vcpkg
60
+
61
+ Installing using vcpkg
62
+ ======================
63
+
64
+ .. note ::
65
+ This page will not detail how to get started using vcpkg _. For that, refer to
66
+ `Get started with vcpkg `__
67
+
68
+ __ https://vcpkg.io/en/getting-started
69
+
70
+ .. tab-set ::
71
+
72
+ .. tab-item :: vcpkg Manifest Mode (Recommended)
73
+
74
+ In `vcpkg manifest mode `__, add the desired libraries to your project's
75
+ ``vcpkg.json `` manifest file:
76
+
77
+ __ https://learn.microsoft.com/en-us/vcpkg/users/manifests
78
+
79
+ .. code-block :: js
80
+ : caption: ` ` vcpkg .json ` `
81
+ : linenos:
82
+
83
+ {
84
+ // ...
85
+ " dependencies" : [
86
+ // ...
87
+ " mongo-c-driver"
88
+ ]
89
+ }
90
+
91
+ When you build a CMake project with vcpkg integration and have a
92
+ ``vcpkg.json `` manifest file, vcpkg will automatically install the project's
93
+ dependencies before proceeding with the configuration phase, so no
94
+ additional manual work is required.
95
+
96
+
97
+ .. tab-item :: vcpkg Classic Mode
98
+
99
+ In `vcpkg classic mode `__, |libbson | and |libmongoc | can be installed through the
100
+ names ``libbson `` and ``mongo-c-driver ``, respectively::
101
+
102
+ $ vcpkg install mongo-c-driver
103
+
104
+ __ https://learn.microsoft.com/en-us/vcpkg/users/classic-mode
105
+
106
+ (Installing ``mongo-c-driver `` will transitively install |libbson | as well.)
107
+
108
+ When the |libmongoc | and |libbson | packages are installed and vcpkg has been
109
+ properly integrated into your build system, the desired libraries will be
110
+ available for import.
111
+
112
+ With CMake, the standard config-file package will be available, as well as the
113
+ generated ``IMPORTED `` targets:
114
+
115
+ .. code-block :: cmake
116
+ :caption: ``CMakeLists.txt``
117
+
118
+ find_package(mongoc-1.0 CONFIG REQUIRED)
119
+ target_link_libraries(my-application
120
+ PRIVATE $<IF:$<TARGET_EXISTS:mongo::mongoc_shared>,mongo::mongoc_shared,mongo::mongoc_static>)
121
+
122
+ .. note ::
123
+
124
+ The large ``$<IF:$<TARGET_EXISTS...>:...> `` generator expression
125
+ (:external:doc: `manual/cmake-generator-expressions.7 `) can be used to switch
126
+ the link type of |libmongoc | based on whichever form is available from the
127
+ ``find_package() `` command. |libmongoc | supports building with both *dynamic *
128
+ and *static * library types, but vcpkg will only install one of the two library
129
+ types at a time.
130
+
131
+ Configuring a CMake project with vcpkg integration is a matter of setting the
132
+ CMake toolchain file at the initial configure command::
133
+
134
+ $ cmake -S . -B _build -D CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
135
+
136
+ .. index ::
137
+ ! pair: Linux; installation
138
+ :name: installing.linux
35
139
36
140
Installing in Linux
37
141
*******************
@@ -48,7 +152,20 @@ The following Linux distributions provide |libbson| and |libmongoc| packages:
48
152
- `Debian <debian _>`_ and Debian-based distributions, including
49
153
`Ubuntu <debian _>`_ and Ubuntu derivatives, via APT.
50
154
155
+ .. seealso ::
156
+
157
+ For a list of available packages and package options, see:
158
+ :doc: `/ref/packages `.
51
159
160
+
161
+ .. index ::
162
+ !pair: installation; RHEL
163
+ !pair: installation; Fedora
164
+ !pair: installation; CentOS
165
+ !pair: installation; Rocky Linux
166
+ !pair: installation; AlmaLinux
167
+ !pair: installation; Yum
168
+ !pair: installation; DNF
52
169
.. _redhat :
53
170
54
171
RedHat-based Systems
@@ -91,6 +208,10 @@ To install the full C database driver (|libmongoc|), install
91
208
# yum install mongo-c-driver-devel
92
209
93
210
211
+ .. index ::
212
+ !pair: installation; Debian
213
+ !pair: installation; Ubuntu
214
+ !pair: installation; APT
94
215
.. _debian :
95
216
96
217
Debian-based Systems
@@ -112,26 +233,25 @@ To install |libmongoc| (which will also install |libbson|)::
112
233
# apt install libmongoc-dev
113
234
114
235
115
- .. _macos :
236
+ .. index ::
237
+ !pair: installation; macOS
238
+ !pair: installation; Homebrew
239
+ package managers; Homebrew
240
+ .. _installing.macos :
116
241
117
242
Installing on macOS with Homebrew
118
243
*********************************
119
244
120
245
If you are using a macOS system, the C driver libraries (including both
121
- |libmongoc | and |libbson |) may be installed using the Homebrew _ package manager [ #macos_brew ]_
122
- with the following command::
246
+ |libmongoc | and |libbson |) may be installed using the Homebrew _ package manager
247
+ [ #macos_brew ]_ with the following command::
123
248
124
249
$ brew install mongo-c-driver
125
250
126
251
.. note ::
127
252
128
253
Homebrew does not provide separate packages for |libbson | and |libmongoc |.
129
254
130
-
131
- .. todo
132
- Packages for Windows, via Conan, and via vcpkg
133
-
134
-
135
255
.. [#macos_brew ]
136
256
137
257
The Homebrew _ package manager is not installed by default on macOS. For
0 commit comments