mongocxx generate build files failed

Its my first time trying to use mongodb for a c++ project. I’ve been following the official tutorial on how to set it up but i can’t get passed the c++ files part. I really need this to work but i don’t know what to do.
– Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
– No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download C driver version 1.25.0 from the internet.
– Download and configure C driver version 1.25.0 … begin
– Using bundled libbson
– libmongoc version (from VERSION_CURRENT file): 1.25.0
– Enabling zlib compression (bundled)
– Searching for compression library zstd
– Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
– Not found
– libmongoc TLS : SecureChannel
– Using SASL backend : SSPI
– Searching for compression library header snappy-c.h
– Not found (specify -DCMAKE_INCLUDE_PATH=/path/to/snappy/include for Snappy compression)
– Searching for libmongocrypt
– libmongocrypt not found. Configuring without Client-Side Field Level Encryption support.
– Compiling against Windows SSPI
– Enabling utf8proc (bundled)
– Building with MONGODB-AWS auth support
– Build files generated for:
– build system: Visual Studio 17 2022
– instance: C:/Program Files/Microsoft Visual Studio/2022/Community
– instance: x64
– The following features have been enabled:

  • TLS, for secure network communication (SecureChannel)
  • Cryptography, cryptographic primitives (SecureChannel)
  • AWS Authentication, authenticate with MongoDB servers using credentials from AWS instance metadata
  • SASL Authentication, authenticate with MongoDB servers using SASL: “Simple Authentication and Security Layer” (SSPI)

– Download and configure C driver version 1.25.0 … end
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File “C:\Repos\mongo-cxx-driver-r3.10.1\etc\calc_release_version.py”, line 370, in
RELEASE_VER = main()
^^^^^^
File “C:\Repos\mongo-cxx-driver-r3.10.1\etc\calc_release_version.py”, line 325, in main
head_commit_short = check_output([‘git’, ‘rev-parse’, ‘–revs-only’,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Repos\mongo-cxx-driver-r3.10.1\etc\calc_release_version.py”, line 131, in check_output
raise subprocess.CalledProcessError(ret, args[0])
subprocess.CalledProcessError: Command ‘git’ returned non-zero exit status 128.
CMake Error at CMakeLists.txt:271 (message):
BUILD_VERSION not specified and could not be calculated (script invocation
failed); specify in CMake command, -DBUILD_VERSION=

– Configuring incomplete, errors occurred!
This is what i get after i run cmake … -G “Visual Studio 17 2022” -A x64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_PREFIX_PATH=C:\mongo-c-driver -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver
I had not problems with generating the C files
Thank you so much for any help

Hi @Tecleanu_Ionut

There seems to be two issues here:

  1. C Driver not found even though you have specified it in the CMAKE_PREFIX_PATH. Please double check the path to the C Driver is correct.
    Because C driver isn’t found, the C++ driver attempts to download and build it, running into issue #2 below.

  2. You are running into CDRIVER-4809. It was fixed in 1.26.0 and above. The workaround for this is to add a file named “VERSION_CURRENT” with content being the version of the C driver (for eg. 1.25.0) in the root of your C driver source. directory.

PS: I’m assuming you built C Driver 1.26.0 or above already and intending to supply that path in the DCMAKE_PREFIX_PATH