Left click over your project item in Solution Explorer, and choose Properties menu;
On VC++ Directory page, add this entries into Include Directories list:
- $(ProjectDir)third-party\boost_1_56_0
- $(ProjectDir)third-party\mongo-cxx-driver\include\mongocxx\v_noabi
- $(ProjectDir)third-party\mongo-cxx-driver\include\bsoncxx\v_noabi
- $(ProjectDir)third-party\mongo-c-driver\include\libmongoc-1.0
- $(ProjectDir)third-party\mongo-c-driver\include\libbson-1.0
On VC++ Directory page, add this entries into Library Directories list:
- $(ProjectDir)third-party\mongo-cxx-driver\lib
- $(ProjectDir)third-party\mongo-c-driver\lib
On Linker/Input page, add this entries into Additional Dependencies:
- bsoncxx.lib
- libbsoncxx.lib
- libmongocxx.lib
- mongocxx.lib
I am trying to install and use MongoDB C++ driver on Windows 10 Pro.
I use Boost v. 1.64.0 downloaded from the official website.
First, I have installed the MongoDB C driver v. 1.6.3 following the official instructions.
Then, I have installed the MongoDB C++ driver v. r3.1.1 following the official instructions and using the following cmake command:
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver -DCMAKE_PREFIX_PATH=c:\mongo-c-driver -DBOOST_ROOT=C:\boost_1_64_0 -DBSONCXX_POLY_USE_BOOST=1 -DLIBBSON_DIR=C:\mongo-c-driver -DLIBMONGOC_DIR=C:\mongo-c-driver
With Microsoft Visual Studio Community 2017 v. 15.2 Release, I have entered the configuration properties shared here:
Left click over your project item in Solution Explorer, and choose Properties menu;
On VC++ Directory page, add this entries into Include Directories list:
- $(ProjectDir)third-party\boost_1_56_0
it compiles successfully as a release x64 solution.
However, the console outputs strange symbols, then crashes. I guess the issue comes from bsoncxx. Indeed, I have the very same problem with this minimal code:
#include <iostream>
#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/json.hpp>
int main(int, char**) {
bsoncxx::builder::basic::document doc{};
doc.append(bsoncxx::builder::basic::kvp("test", 1));
std::cout << bsoncxx::to_json(doc) << std::endl;
}
Thank you for your help.
All of the above looks fine. However, could you please include the msbuild invocation you used to compile and install the driver after running CMake?
msbuild.exe ALL_BUILD.vcxproj
(There were errors due to a missing "#include <assert.h>" in mock.hh. It was fixed easily. I re-ran the command successfully).
Then,
msbuild.exe INSTALL.vcxproj
No errors.
As an FYI, our current testing for the driver does not include VS 2017, only VS 2015. It is possible that you are finding novel (mis-)behavior.
Is this a typo, or are you really building your project against a different version of boost? If so, it is very unlikely to work. You should build your application and the driver against the same version of boost.
I assume you are doing this so you don't need a PATH set?
My suspicion here is that you have a mismatch somewhere between the application, boost, and the C++ driver regarding which version of boost or the runtime library you are using, though it isn't obvious to me where, unless it is the boost version thing above. Please double check that all components are using the same runtime library (dynamic vs static, single vs multi-threaded, debug vs retail). Mismatches here are a common cause of strange and hard to diagnose runtime errors, because the layout of types like std::string is inconsistent across function call boundaries.
Thank you very much for your quick reply.All of the above looks fine. However, could you please include the msbuild invocation you used to compile and install the driver after running CMake?
In Visual Studio 2017 Developer Command Prompt v15.0.26430.15, I invoked:msbuild.exe ALL_BUILD.vcxproj
(There were errors due to a missing "#include <assert.h>" in mock.hh. It was fixed easily. I re-ran the command successfully).
Then,
msbuild.exe INSTALL.vcxproj
No errors.
As an FYI, our current testing for the driver does not include VS 2017, only VS 2015. It is possible that you are finding novel (mis-)behavior.
Indeed. Do you know if/when you plan to include VS 2017 in your testing?
Is this a typo, or are you really building your project against a different version of boost? If so, it is very unlikely to work. You should build your application and the driver against the same version of boost.
This is a typo: my VS configuration correctly refers to my version of Boost (C:\boost_1_64_0).
I assume you are doing this so you don't need a PATH set?
This is the way I usually do it, but there is probably a better practice. I would be grateful to any advice in this matter.
My suspicion here is that you have a mismatch somewhere between the application, boost, and the C++ driver regarding which version of boost or the runtime library you are using, though it isn't obvious to me where, unless it is the boost version thing above. Please double check that all components are using the same runtime library (dynamic vs static, single vs multi-threaded, debug vs retail). Mismatches here are a common cause of strange and hard to diagnose runtime errors, because the layout of types like std::string is inconsistent across function call boundaries.
I will do my best to re-check everything. If I find something useful, I will share it here.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/d8c45418-d761-4877-a3c9-d84edb8cc27c%40googlegroups.com.