Skip to content

As requested, add detailed installation instructions for Vcpkg and Conan #1031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 16, 2023
87 changes: 87 additions & 0 deletions docs/content/mongocxx-v3/installation/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,93 @@ To configure and install the driver, follow the instructions for your platform:
The Mongo C++ driver is available in the following package managers.
- [Vcpkg](https://vcpkg.io/) (search for mongo-cxx-driver)
- [Conan](https://conan.io/center/recipes/mongo-cxx-driver)
- [Homebrew](https://formulae.brew.sh/formula/mongo-cxx-driver)

### Vcpkg Install Instructions

If you do not already have Vcpkg installed, install it with the following
command:
```
$ git clone https://github.com/Microsoft/vcpkg.git
$ cd vcpkg
$ ./bootstrap-vcpkg.sh
```

Optionally, to install with Visual Studio integration:
```
vcpkg integrate install
```

Install the driver. (You may need to `git pull` to get the latest version of the
driver)
```
$ ./vcpkg install mongo-cxx-driver
```

You can use the toolchain file, `vcpkg.cmake`, to instruct CMake where to find
the development files, for example:
```
-DCMAKE_TOOLCHAIN_FILE=/<path to vcpkg repo>/vcpkg/scripts/buildsystems/vcpkg.cmake
```

You can find the header files in:
```
vcpkg/installed/<CPU ARCHITECTURE>-<OPERATING SYSTEM>/include/
```

The library files are in:
```
vcpkg/installed/<CPU ARCHITECTURE>-<OPERATING SYSTEM>/lib/
```
Comment on lines +67 to +75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vcpkg recommends using the vcpkg.cmake pre-include file for CMake projects, and prefers the new "manifest mode" when possible. I would note both of those here with external documentation links.


### Conan Install Instructions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include an up-front notice hat the package specifier is mongo-cxx-driver/<version>. More advanced Conan users will look for this information specifically. Same recommendation for the vcpkg section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I added the following line for the Conan documentation, but since Vcpkg handles versioning entirely through git, what is your recommendation for Vcpkg?

Package Specifier: `mongo-cxx-driver/3.8.0`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For vcpkg, just the package name is enough for anyone to get started quickly. Maybe leave a note that the version may be out of date on older vcpkg versions.


Package Specifier: `mongo-cxx-driver/3.8.0`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.8.1 is now available (as of yesterday)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently have a PR open with Conan to update their version to 3.8.1. I'll update the version in the instructions once it gets merged: conan-io/conan-center-index#20504


If you do not already have Conan installed, then install it and run the Conan
initalization command below:
```
$ pip install conan
$ conan profile detect --force
```

Add the following to your `conanfile.txt`
```
[requires]
mongo-cxx-driver/3.8.0
[generators]
CMakeDeps
CMakeToolchain
```

Install the driver via Conan, and build your project:
```
$ conan install conanfile.txt --output-folder=build --build=missing
$ cmake \
-B build \
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release
$ cmake --build build
```

### Homebrew

For MacOS users, homebrew is a convienent way to install the C++ driver.

```
brew install mongo-cxx-driver
```

Headers can be found in:
```
/opt/homebrew/include/mongocxx/v_noabi/
/opt/homebrew/include/bsoncxx/v_noabi/
```

Library files can be found in:
```
/opt/homebrew/lib/
```

## Docker Image

Expand Down