Issue
I'm trying to build mongo-cxx-driver
on Windows; I'm following the instructions, but am getting errors:
C1189 #error: "Cannot find a valid polyfill for make_unique"
Here's what I did:
Building mongo-c-driver
I cloned mongo-c-driver
using the specified minimum release (1.15):
git clone https://github.com/mongodb/mongo-c-driver --branch r1.15
Using CMake-Gui (I'm using 3.18.2), I generated the .proj file using Visual Studio 16 2019 Generator. I used the default settings:
This builds successfully, and I can find the corresponding .dll and .lib files in C:\Program Files (x86)\mongo-c-driver
.
Building mongo-cxx-driver
I cloned the project using my desired version (compatible with the above version of mongo-c-driver
):
git clone https://github.com/mongodb/mongo-cxx-driver --branch releases/v3.5
I used Cmake-Gui to configure the CMake parameters, configuring the paths to where I installed mongo-c
:
Of note:
- I did not fill out
bson-1.0_DIR
ormongoc-1.0_DIR
because I can't figure out what they're looking for. - I set
BSONCXX_POLY_USE_STD=1
because I am using C++17 and do not want to usestd::experimental
or Boost.
I tried to compile this in Visual Studio, and got the above error about not finding a valid polyfill for make_unique
. Where did I go wrong?
thank you!
Solution
The answer seems to be in the installation guide, I missed a step:
For building with Visual Studio 2017 (without a C++17 polyfill), it is necessary to configure with an additional option, /Zc:__cplusplus to opt into the correct definition of __cplusplus (problem described here):
'C:\Program Files (x86)\CMake\bin\cmake.exe' ..
-G "Visual Studio 15 2017 Win64"
-DCMAKE_CXX_STANDARD=17
-DCMAKE_CXX_FLAGS="/Zc:__cplusplus"
-DCMAKE_PREFIX_PATH=C:\mongo-c-driver
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \
I added the "/Zc:__cplusplus" flag as required and it compiled fine!
Answered By - nathan lachenmyer