问题描述
我正在尝试在Windows上构建mongo-cxx-driver
;我正在追踪instructions,但遇到错误:
C1189 #error: "Cannot find a valid polyfill for make_unique"
这就是我所做的:
构建mongo-c-driver
我使用指定的最低版本(1.15)克隆了mongo-c-driver
:
git clone https://github.com/mongodb/mongo-c-driver --branch r1.15
使用CMake-Gui(我正在使用3.18.2),我使用Visual Studio 16 2019 Generator生成了.proj文件。我使用默认设置:
这成功构建,我可以在C:\Program Files (x86)\mongo-c-driver
中找到相应的.dll和.lib文件。
构建mongo-cxx-driver
我使用所需版本(与上述mongo-c-driver
版本兼容)克隆了该项目:
git clone https://github.com/mongodb/mongo-cxx-driver --branch releases/v3.5
我使用Cmake-Gui来配置CMake参数,并配置了安装mongo-c
的路径:
值得注意的是:
- 我没有填写
bson-1.0_DIR
或mongoc-1.0_DIR
,因为我不知道他们在找什么。 - 我设置
BSONCXX_poly_USE_STD=1
是因为我正在使用C ++ 17,并且不想使用std::experimental
或Boost。
我试图在Visual Studio中进行编译,但遇到了关于找不到make_unique
的有效polyfill的上述错误。我哪里出错了?
谢谢!
解决方法
答案似乎在installation guide中,我错过了一步:
对于使用Visual Studio 2017进行构建(不使用C ++ 17 polyfill),它是 配置其他选项/ Zc:__ cplusplus所必需 选择__cplusplus的正确定义(问题描述 这里):
'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 \
我根据需要添加了“ / Zc:__ cplusplus”标志,并且编译良好!