2

I'm trying to build the mongo-cxx-driver (eventually), and the first step is to build the mongo-c-driver (which requires libbson).

I'm running Windows 10 and using Visual Studio 2015 as my compiler. I was able to run CMake and build libbson just fine all of the projects built just fine. Now I have copies of bson-static-1.0.lib built in mongo-c-driver/src/libbson/build/Debug/ and mongo-c-driver/src/libbson/build/Release/. This seems like everything is correct.

The next step is to build the mongo-c-driver. I ran CMake and tried to create the Visual Studio solutions, but got the errors:

Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing:  OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) 
Searching for sasl/sasl.h
  Not found (specify -DCMAKE_INCLUDE_PATH=C:/path/to/sasl/include for SASL support)
Searching for libsasl2
  Not found (specify -DCMAKE_LIBRARY_PATH=C:/path/to/sasl/lib for SASL support)
Current version (from VERSION_CURRENT file): 1.3.5
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
BSON (ADVANCED)
    linked by target "mongoc_shared" in directory C:/Users/sdf/Downloads/mongo-c-driver-1.3.5
    linked by target "mongoc_static" in directory C:/Users/sdf/Downloads/mongo-c-driver-1.3.5

Configuring incomplete, errors occurred!
See also "C:/Users/sdf/Downloads/mongo-c-driver-1.3.5/build/CMakeFiles/CMakeOutput.log".

It looks like the variable BSON isn't set to the right value -- it's value is BSON-NOTFOUND right now. Does anyone know what the correct value is for BSON, and if it should have gotten set automatically during the process of compiling libbson?

nathan lachenmyer
  • 5,298
  • 8
  • 36
  • 57

3 Answers3

1

Smart way of compiling MongoDB c++ driver.use vcpkg

Download vcpkg follow the instructions as mentioned on git. https://github.com/Microsoft/vcpkg

Step 1 C:\vcpkg>.\vcpkg search mongodb

Step 2 C:.\vcpkg search mongodb install mongo-cxx-driver

Stap 3 C:\vcpkg>.\vcpkg integrate install

useful link.https://stackoverflow.com/a/46981525/8617780

Joyo Waseem
  • 680
  • 8
  • 25
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/17761696) – Jeff Zeitlin Oct 27 '17 at 19:45
  • you are correct, I have edited my answer. @Jeff Zeitlin – Joyo Waseem Oct 27 '17 at 20:05
0

Please follow the "installing on Windows" instructions carefully:

https://api.mongodb.com/c/current/installing.html#building-windows

It seems you're missing the part where you set CMAKE_INSTALL_PREFIX when building libbson, then install libbson and build libmongoc with the same CMAKE_INSTALL_PREFIX setting.

A. Jesse Jiryu Davis
  • 23,641
  • 4
  • 57
  • 70
0

First, you need build INSTALL project in libbson sln (run vs in admin mode, because it need create lib folders like linux way)

Then define BSON_INCLUDE_DIR to include folder which the INSTALL project created and BSON to lib file you build for example C:/Program Files/libbson/lib/bson-static-1.0.lib in cmake (This BSON naming is problematic, should rename to BSON_LIB)

jean
  • 2,825
  • 2
  • 35
  • 72