3

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

Héctor
  • 399
  • 3
  • 16
  • If a project supports CMake then "Missing information cmake_minimum_required & project" almost always means you are running CMake from the wrong directory. Find the most toplevel directory where the `CMakeLists.txt` file contains those information and rerun your commands from there. – vre Apr 01 '20 at 18:34
  • I was at the top level directory (mongo-c-driver-1.16.2). I checked it again. – Héctor Apr 01 '20 at 18:46
  • Okay, I have found that I can get the x64 version on vcpkg with the "--triplet x64-windows" options. But I still get the 1.0 version. I also continue without knowing why the first way isn't working. – Héctor Apr 01 '20 at 19:22
  • 1
    As a general note: the version isn't typically present in a *.dll* name. If it was, imagine *software-x.y.dll* When a new minor version was released it would be *software-x.y+1.dll*, meaning that all software that uses that *.dll* would have to be recompiled, which makes no sense. I didn't work with *Mongo*, but *1.0* seems fine. Right click on the file *Properties->Details* (maybe the version is stored there). – CristiFati Apr 01 '20 at 20:06
  • OK. Just downloaded the last version 1.16.2 and followed the instructions. My command line call for a cmd command prompt was `cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..` from the build dir. I could run CMake on this project without any hassle. Do you run this command from a cmd or a powershell or something other? – vre Apr 01 '20 at 20:11
  • @CristiFati Yes, that makes sense. Maybe now I have the 1.15.1 version that is from one year ago, but that it's much better than having nothing. – Héctor Apr 01 '20 at 20:59
  • @Héctor: You didn't get my point. What I was trying to say that the *1.0* at the end at the *.dll* name is not necessarily the version. Could be *1.16.2*, or *1.15*, or *1.\**. Try alternate ways for finding the version (I gave one in the previous comment, or look at the build logs). But I totally don't get how building a certain version of sources would yield a different version of the artifact. – CristiFati Apr 01 '20 at 21:05
  • @vre from cmd. If I copypaste your command or run mine posted above I get the following error: Unknown CMake command "set_dist_list". – Héctor Apr 01 '20 at 21:08
  • @CristiFati No, I got it. Sorry if I didn't explained well myself. The 1.15.1 was the only version available through vcpckg, that's why I suposed that my version is this one and not 1.0 or 1.16.2 or whatever. The version isn't store on the file properties, I will try to search in the logs. Thanks for your replies. – Héctor Apr 01 '20 at 21:12
  • I am using CMake 3.14.3. Maybe that makes the difference.As CMake 3.17.0 is bleedign edge can you try an older version? – vre Apr 01 '20 at 21:12
  • @vre I have deleted my CMake version and ins taled yours (3.14.3). If I write my command or yours I get the same error output: CMake Error at CMakeLists.txt:39 (set_dist_list): Unknown CMake command "set_dist_list". – Héctor Apr 02 '20 at 06:32
  • @vre Maybe may you upload your 1.16.2 x64 dll? – Héctor Apr 02 '20 at 06:38
  • 1
    What source file did you downloaded from projects GitHub releases? The `Source code (zip)` did not work on my computer. Instead I downloaded the *.tar.gz form this link: https://github.com/mongodb/mongo-c-driver/releases/download/1.16.2/mongo-c-driver-1.16.2.tar.gz – vre Apr 02 '20 at 07:04
  • Wow, now it just works... I downloaded the .zip version. With the .tar.gz works perfectly line by line. Thank you so much. How can I mark you as solution? – Héctor Apr 02 '20 at 07:30

1 Answers1

2

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.

vre
  • 6,041
  • 1
  • 25
  • 39