cmongodbdllcmakemongo-c-driver

Problems building mongo-c-driver-1.16.2 for Win64


I need to compile the MongoDB driver for windows x64 (.dll extension). I was following this tutorial with visual studio 16 2019 and cmake 3.17.0, but I found several problems:

  1. First step is:
$ cd mongo-c-driver-x.y.z
$ mkdir cmake-build
$ cd cmake-build
$ cmake -G "Visual Studio 14 2015 Win64" \
    "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" \
    "-DCMAKE_PREFIX_PATH=C:\mongo-c-driver" \
    ..

But I received errors about missing information at top of the CMakeLists.txt file. cmake_minimum_required & project(). So I wrote them.

  1. Then, at the end of the file it was written the following:
set_dist_list (src_libmongoc_tests_DIST
   CMakeLists.txt
   ${src_libmongoc_tests_DIST_cs}
   ${src_libmongoc_tests_DIST_hs}
   ${src_libmongoc_tests_DIST_zeros}
   ${src_libmongoc_tests_DIST_pems}
   ${src_libmongoc_tests_DIST_dats}
   ${src_libmongoc_tests_DIST_txts}
   ${src_libmongoc_tests_DIST_jsons}
)

I had to erase it because of error with the set_dist_list command

  1. Once erased it worked well with the command:
cmake -G "Visual Studio 16 2019" -A "x64" -S "C:\...\mongo-c-driver-1.16.2" -B "C:\...\mongo-c-driver-1.16.2\cmake-build3" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" "-DCMAKE_PREFIX_PATH=C:\mongo-c-driver"
  1. Next step was:
$ msbuild.exe /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj

It worked well.

  1. Next step was:
$ msbuild.exe INSTALL.vcxproj

There wasn't INSTALL.vcxproj file, so I couldn't execute the command. I tried several times but didn't find solution to the problem. But I found this on stackoverflow. I followed all the steps but when I searched for mongo-c-driver there was only the 1.15.1 available. I continued anyways but when the process finished I found that the drivers where x86 and not x64 (they're in a folder called x86-windows) and the drivers seem to be 1.0 version (they are called libmongoc-1.0.dll & libbson-1.0.dll).

So, the conclusion is that I wasted a lot of time I couldn't build the drivers. What I did wrong on both processes? How I can get the last version of the mongo-c-driver compiled for x64 on .dll format?

Many thanks for your time and responses, I don't know how to continue,

Héctor


Solution

  • The tutorial for building mongo-c-driver on Windows is missing the step which source should be downloaded (as the paragraphs for other platforms provide). So one might be tempted to download Source code (zip) from the releases page. This will only get you a copy of the repository when the tag was set. But it is essential to use the mongo-c-driver-1.16.2.tar.gz link on the releases page. Then everything should work.