1

我正在使用这个http://mongocxx.org/在 Windows 上安装 mongo DB C++ 驱动程序。我的目标是使用 C++ 在 Qt Creator 上编写 mongo dB 代码。所以我是初学者,所以上面链接中给出的步骤没有详细说明。如果有人以前这样做过,请用简单的方式描述...

编辑:我试图使用链接http://mongoc.org/libmongoc/current/installing.html中显示的 mingw64 构建驱动程序文件,但 显示错误。

LD-RD2@LD-RD2 MINGW64 ~/mongo-c-driver-1.18.0/cmake-build
# cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/LD-RD2/AppData/Roaming/SPB_Data/mongo-c-driver-1.18.0/cmake-build/CMakeFiles/CMakeOutput.log".

更新:错误

LD-RD2@LD-RD2 MINGW64 ~/mongo-cxx-driver-r3.6.5/build2
# ‘C:\Program Files\CMake\bin\cmake.exe’ … \
-G "MSYS Makefiles"           \
-DCMAKE_PREFIX_PATH=C:\Program Files (x86)\mongo-c-driver       \
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ..
-bash: syntax error near unexpected token `('
-bash: -DCMAKE_INSTALL_PREFIX=C:mongo-cxx-driver: command not found

LD-RD2@LD-RD2 MINGW64 ~/mongo-cxx-driver-r3.6.5/build2
# cmake -G "MSYS Makefiles"           \
-DCMAKE_PREFIX_PATH=C:\Program Files (x86)\mongo-c-driver       \
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ..
-bash: syntax error near unexpected token `('
-bash: -DCMAKE_INSTALL_PREFIX=C:mongo-cxx-driver: command not found
4

1 回答 1

1

您可以通过执行以下操作告诉 CMake 生成标准 makefile:

cmake -G "Unix Makefiles" -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..

或者,您可以只安装 Ninja(并使其在您的 $PATH 上可用),这是 CMake 目标的更好选择。

检查cmake --help哪些生成器可用,您可能需要改用“MSYS Makefiles”生成器。

于 2021-08-12T09:28:16.773 回答