@@ -131,6 +131,20 @@ cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 \
131
131
-DCMAKE_INSTALL_PREFIX=/usr/local ..
132
132
```
133
133
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:\m ongo-cxx-driver
143
+ -DLIBBSON_DIR=c:\m ongo-c-driver
144
+ -DBOOST_ROOT=c:\l ocal\b oost_1_59_0
145
+ -DLIBMONGOC_DIR=c:\m ongo-c-driver
146
+ ```
147
+
134
148
### Step 5: Build and install the driver
135
149
136
150
If you are using the default MNMLSTC polyfill and are installing to a
@@ -150,6 +164,13 @@ build and install the driver:
150
164
make && sudo make install
151
165
```
152
166
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
+
153
174
### Step 6: Test your installation
154
175
155
176
Save the following source file with the filename ` test.cpp `
@@ -211,3 +232,34 @@ c++ --std=c++11 test.cpp -o test \
211
232
-I/usr/local/include/bsoncxx/v_noabi -I/usr/local/include/libbson-1.0 \
212
233
-L/usr/local/lib -lmongocxx -lbsoncxx
213
234
```
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