You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CXX-2579 use standard directories in main install instructions (#944)
* fix link rendering on configuration page
* include `/lib` in CMAKE_INSTALL_RPATH instruction
And explain rationale. This can help a consumer locate libbsoncxx.so if the consumer only links to full path of libmongocxx.so.
* replace `/opt/` with `$HOME`
To prevent requiring users to have additional permissions.
Installing to `/opt` on macOS requires root permissions.
* add "Installing to non-standard directories" section to advanced.md
* add instructions for specifying a custom C driver install
* use standard install directories in main installation instructions
* add instructions for fixes to locate shared libraries
* use <install-dir>, not /usr/local, for uninstall example
Co-authored-by: Ezra Chung <[email protected]>
* exclude `CMAKE_PREFIX_PATH` or `CMAKE_INSTALL_PREFIX` from unrelated examples
* combine `For Linux and macOS` and `For Windows` sections
The instructions are no longer platform specific.
---------
Co-authored-by: Ezra Chung <[email protected]>
object and passing it to `tls_opts` on mongocxx::options::client.
26
26
27
27
For example, to use a custom CA or to disable certificate validation,
@@ -109,7 +109,7 @@ See the MongoDB server
109
109
for more information about determining the subject name from the
110
110
certificate.
111
111
112
-
The PEM file can also be specified using the [mongocxx::options::tls]({{< api3ref classmongocxx_1_1options_1_1tls >}}) class, see the first "Configuring TLS/SSL" example above.
112
+
The PEM file can also be specified using the [mongocxx::options::tls]({{< api3ref classmongocxx_1_1options_1_1tls >}}) class, see the first "Configuring TLS/SSL" example above.
If building the application with cmake, the [Default RPATH settings](https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#default-rpath-settings) include the full RPATH to all used libraries in the build tree. However, when installing, cmake will clear the RPATH of these targets so they are installed with an empty RPATH. This may result in a `Library not loaded` error after install.
167
+
168
+
Example:
169
+
```sh
170
+
# Build application `app` using the C++ driver from a non-standard install.
171
+
cmake \
172
+
-DCMAKE_PREFIX_PATH=$HOME/mongo-cxx-driver \
173
+
-DCMAKE_INSTALL_PREFIX=$HOME/app \
174
+
-DCMAKE_CXX_STANDARD=11 \
175
+
-Bcmake-build -S.
176
+
cmake --build cmake-build --target app.out
177
+
# Running app.out from build tree includes rpath to C++ driver.
178
+
./cmake-build ./cmake-build/app.out
179
+
# Prints: "successfully connected with C++ driver"
180
+
181
+
cmake --build cmake-build --target install
182
+
# Running app.out from install tree does not include rpath to C++ driver.
183
+
$HOME/app/bin/app.out
184
+
# Prints "Library not loaded" error.
185
+
```
186
+
187
+
Consider setting `-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE` so the rpath for the executable is kept in the install target.
188
+
```sh
189
+
# Build application `app` using the C++ driver from a non-standard install.
190
+
# Use CMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE to keep rpath entry on installed app.
191
+
cmake \
192
+
-DCMAKE_PREFIX_PATH=$HOME/mongo-cxx-driver \
193
+
-DCMAKE_INSTALL_PREFIX=$HOME/app \
194
+
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \
195
+
-DCMAKE_CXX_STANDARD=11 \
196
+
-Bcmake-build -S.
197
+
198
+
cmake --build cmake-build --target install
199
+
$HOME/app/bin/app.out
200
+
# Prints "successfully connected with C++ driver"
201
+
```
202
+
203
+
See the cmake documentation for [RPATH handling](https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling) for more information.
204
+
205
+
### Fixing the "cannot open shared object file" error on Linux
206
+
207
+
Applications linking to a non-standard directory installation may encounter an error loading the C++ driver at runtime. Example:
208
+
209
+
```sh
210
+
# Tell pkg-config where to find C++ driver installation.
If building the application with cmake, the [Default RPATH settings](https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#default-rpath-settings) include the full RPATH to all used libraries in the build tree. However, when installing, cmake will clear the RPATH of these targets so they are installed with an empty RPATH. This may result in a `Library not loaded` error after install.
238
+
239
+
Example:
240
+
```sh
241
+
# Build application `app` using the C++ driver from a non-standard install.
242
+
cmake \
243
+
-DCMAKE_PREFIX_PATH=$HOME/mongo-cxx-driver \
244
+
-DCMAKE_INSTALL_PREFIX=$HOME/app \
245
+
-DCMAKE_CXX_STANDARD=11 \
246
+
-Bcmake-build -S.
247
+
cmake --build cmake-build --target app.out
248
+
# Running app.out from build tree includes rpath to C++ driver.
249
+
./cmake-build ./cmake-build/app.out
250
+
# Prints: "successfully connected with C++ driver"
251
+
252
+
cmake --build cmake-build --target install
253
+
# Running app.out from install tree does not include rpath to C++ driver.
254
+
$HOME/app/bin/app.out
255
+
# Prints "cannot open shared object file" error.
256
+
```
257
+
258
+
Consider setting `-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE` so the rpath for the executable is kept in the install target.
259
+
```sh
260
+
# Build application `app` using the C++ driver from a non-standard install.
261
+
# Use CMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE to keep rpath entry on installed app.
262
+
cmake \
263
+
-DCMAKE_PREFIX_PATH=$HOME/mongo-cxx-driver \
264
+
-DCMAKE_INSTALL_PREFIX=$HOME/app \
265
+
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \
266
+
-DCMAKE_CXX_STANDARD=11 \
267
+
-Bcmake-build -S.
268
+
269
+
cmake --build cmake-build --target install
270
+
$HOME/app/bin/app.out
271
+
# Prints "successfully connected with C++ driver"
272
+
```
273
+
274
+
See the cmake documentation for [RPATH handling](https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling) for more information.
0 commit comments