[英]mongo-cxx driver cannot find polyfill for unique_ptr
I'm trying to build mongo-cxx-driver
on Windows;我正在尝试在 Windows 上构建mongo-cxx-driver
; I'm following the instructions , but am getting errors:我正在按照说明进行操作,但出现错误:
C1189 #error: "Cannot find a valid polyfill for make_unique"
Here's what I did:这是我所做的:
I cloned mongo-c-driver
using the specified minimum release (1.15):我使用指定的最低版本 (1.15) 克隆了mongo-c-driver
:
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.使用 CMake-Gui(我使用的是 3.18.2),我使用 Visual Studio 16 2019 Generator 生成了 .proj 文件。 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
.这构建成功,我可以在C:\\Program Files (x86)\\mongo-c-driver
找到相应的 .dll 和 .lib 文件。
I cloned the project using my desired version (compatible with the above version of mongo-c-driver
):我使用我想要的版本(与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
:我使用 Cmake-Gui 来配置 CMake 参数,配置到我安装mongo-c
的路径:
Of note:值得注意的是:
bson-1.0_DIR
or mongoc-1.0_DIR
because I can't figure out what they're looking for.我没有填写bson-1.0_DIR
或mongoc-1.0_DIR
因为我不知道他们在找什么。BSONCXX_POLY_USE_STD=1
because I am using C++17 and do not want to use std::experimental
or Boost.我设置BSONCXX_POLY_USE_STD=1
因为我使用的是 C++17 并且不想使用std::experimental
或 Boost。 I tried to compile this in Visual Studio, and got the above error about not finding a valid polyfill for make_unique
.我尝试在 Visual Studio 中编译它,并得到上述关于找不到make_unique
的有效make_unique
。 Where did I go wrong?我哪里做错了?
thank you!谢谢你!
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):为了使用 Visual Studio 2017(没有 C++17 polyfill)构建,需要配置一个额外的选项,/Zc:__cplusplus 来选择正确的 __cplusplus 定义(这里描述的问题):
'C:\\Program Files (x86)\\CMake\\bin\\cmake.exe' .. 'C:\\Program Files (x86)\\CMake\\bin\\cmake.exe' ..
-G "Visual Studio 15 2017 Win64" -G "Visual Studio 15 2017 Win64"
-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD=17
-DCMAKE_CXX_FLAGS="/Zc:__cplusplus" -DCMAKE_CXX_FLAGS="/Zc:__cplusplus"
-DCMAKE_PREFIX_PATH=C:\\mongo-c-driver -DCMAKE_PREFIX_PATH=C:\\mongo-c-driver
-DCMAKE_INSTALL_PREFIX=C:\\mongo-cxx-driver \\ -DCMAKE_INSTALL_PREFIX=C:\\mongo-cxx-driver \\
I added the "/Zc:__cplusplus" flag as required and it compiled fine!我根据需要添加了“/Zc:__cplusplus”标志,它编译得很好!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.