Skip to content

Commit dd08821

Browse files
committed
CXX-1155 Add Windows installation instructions to manual
1 parent 391ccce commit dd08821

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

docs/content/mongocxx-v3/installation.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 \
131131
-DCMAKE_INSTALL_PREFIX=/usr/local ..
132132
```
133133

134+
On Windows, here's an example of how to configure for MSVC (assuming
135+
libmongoc and libbson are in `c:\mongo-c-driver` as given in the
136+
[mongoc Windows installation
137+
instructions](http://mongoc.org/libmongoc/current/installing.html#building-windows)
138+
and boost is in `c:\local\boost_1_59_0`:
139+
140+
```sh
141+
'C:\Program Files (x86)\CMake\bin\cmake.exe' -G "Visual Studio 14 Win64"
142+
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver
143+
-DLIBBSON_DIR=c:\mongo-c-driver
144+
-DBOOST_ROOT=c:\local\boost_1_59_0
145+
-DLIBMONGOC_DIR=c:\mongo-c-driver
146+
```
147+
134148
### Step 5: Build and install the driver
135149

136150
If you are using the default MNMLSTC polyfill and are installing to a
@@ -150,6 +164,13 @@ build and install the driver:
150164
make && sudo make install
151165
```
152166

167+
On Windows, build and install from the command line like this:
168+
169+
```sh
170+
msbuild.exe ALL_BUILD.vcxproj
171+
msbuild.exe INSTALL.vcxproj
172+
```
173+
153174
### Step 6: Test your installation
154175

155176
Save the following source file with the filename `test.cpp`
@@ -211,3 +232,34 @@ c++ --std=c++11 test.cpp -o test \
211232
-I/usr/local/include/bsoncxx/v_noabi -I/usr/local/include/libbson-1.0 \
212233
-L/usr/local/lib -lmongocxx -lbsoncxx
213234
```
235+
236+
#### Compiling with MSVC
237+
238+
To compile on MSVC, you will need to setup your project to include all the
239+
necessary include paths, library paths, preprocessor defines, and link
240+
libraries. To do this, you can set these values either by the UI or by
241+
editing the XML `.vcxproj` file directly. To confirm you have everything
242+
setup correctly, here are the `PropertyGroup` and `ItemDefinitionGroup`
243+
settings for a Debug x64 build as an example:
244+
245+
```xml
246+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
247+
<LinkIncremental>true</LinkIncremental>
248+
<IncludePath>c:\local\boost_1_59_0\;C:\mongo-cxx-driver\include\mongocxx\v_noabi;C:\mongo-cxx-driver\include\bsoncxx\v_noabi;C:\mongo-c-driver\include\libmongoc-1.0;C:\mongo-c-driver\include\libbson-1.0;$(IncludePath)</IncludePath>
249+
<LibraryPath>c:\mongo-c-driver\lib\;c:\mongo-cxx-driver\lib\;$(LibraryPath)</LibraryPath>
250+
</PropertyGroup>
251+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
252+
<ClCompile>
253+
<PrecompiledHeader>Use</PrecompiledHeader>
254+
<WarningLevel>Level3</WarningLevel>
255+
<Optimization>Disabled</Optimization>
256+
<PreprocessorDefinitions>MONGOCXX_STATIC;BSONCXX_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
257+
<SDLCheck>true</SDLCheck>
258+
</ClCompile>
259+
<Link>
260+
<SubSystem>Console</SubSystem>
261+
<GenerateDebugInformation>true</GenerateDebugInformation>
262+
<AdditionalDependencies>libmongocxx.lib;libbsoncxx.lib;mongoc-static-1.0.lib;bson-1.0.lib;%(AdditionalDependencies)</AdditionalDependencies>
263+
</Link>
264+
</ItemDefinitionGroup>
265+
```

0 commit comments

Comments
 (0)