Mongo DB C++ Driver build with Cmake

579 views
Skip to first unread message

Apostolos T

unread,
May 24, 2016, 7:07:46 AM5/24/16
to mongodb-user
Hi,

I am trying to build the C++ driver following the instructions provided here: https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-%28New-Driver%29

Unfortunately I am experiencing a few issues.

The information of my setup is as follows: 
  • The version of the driver you are trying to build (branch or tag).
    • Mongo C++ Driver
  • Host OS, version, and architecture.
    • Windows 7 Pro 64bit
  • C++ Compiler and version.
    • MSVC 2015 Community Update 2 (version 14.0.25123.00)
  • Cmake version.
    • 3.5.2
According to your new driver guide there doesn't seem to be any need for the PKG CONFIG tool and instructions on how the installation could be done in a Windows environment.
I successfully built the latest MongoDB C driver version from github, and I tried to use a similar approach for the c++ driver.

Can you please provide instructions for building in a windows environment and whether the PKG Config tool is needed or not? 

Also, after a few efforts I saw in the CMakeLists.txt that for the case of Visual Studio there is a version condition:

"...elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
       if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506")
          message(FATAL_ERROR "Insufficient Microsoft Visual C++ version - MSVC 2015 Update 1+ required") ... "

while the current version of VS2015 Community Update 2 is 14.0.25123.00.

Thank you in advance for your time.
Kind Regards,
Apostolos T.

Andrew Morrow

unread,
May 24, 2016, 9:50:02 AM5/24/16
to mongod...@googlegroups.com
On Tue, May 24, 2016 at 5:36 AM, Apostolos T <apts...@gmail.com> wrote:
Hi,

I am trying to build the C++ driver following the instructions provided here: https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-%28New-Driver%29

Unfortunately I am experiencing a few issues.

The information of my setup is as follows: 
  • The version of the driver you are trying to build (branch or tag).
    • Mongo C++ Driver
  • Host OS, version, and architecture.
    • Windows 7 Pro 64bit
  • C++ Compiler and version.
    • MSVC 2015 Community Update 2 (version 14.0.25123.00)
  • Cmake version.
    • 3.5.2
Thanks for providing this, it is very helpful.

 
According to your new driver guide there doesn't seem to be any need for the PKG CONFIG tool and instructions on how the installation could be done in a Windows environment.

If you don't have pkgconfig on Windows (and I think it is pretty unusual to have it), you will need to explicitly tell the C++11 driver CMake where to find libbson and libmongoc by setting the LIBBSON_DIR and LIBMONGOC_DIR variables explicitly.

It would be better if the C driver installed CMake Find modules, but it currently does not (see https://jira.mongodb.org/browse/CDRIVER-1058)

 
I successfully built the latest MongoDB C driver version from github, and I tried to use a similar approach for the c++ driver.

Can you please provide instructions for building in a windows environment and whether the PKG Config tool is needed or not? 

Per the above, you need to set LIBBSON_DIR and LIBMONGOC_DIR. Please have a look at our AppVeyor configuration for examples:


 


Also, after a few efforts I saw in the CMakeLists.txt that for the case of Visual Studio there is a version condition:

"...elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
       if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506")
          message(FATAL_ERROR "Insufficient Microsoft Visual C++ version - MSVC 2015 Update 1+ required") ... "

while the current version of VS2015 Community Update 2 is 14.0.25123.00.

This is checking the vesrion of Visual C++, not Visual Studio:


I'm reasonably sure that this check is correct? Is it actually issuing the fatal error? Do you have more than one version of Visual C++ installed on this system? How are you specifying which one to use? Are you running inside the configured terminal for one of the VC installs?

Thanks,
Andrew


Apostolos T

unread,
May 26, 2016, 9:03:41 AM5/26/16
to mongodb-user
Dear Andrew,

first of all thank you for taking the time to answer. Please find my comments inline.


Τη Τρίτη, 24 Μαΐου 2016 - 4:50:02 μ.μ. UTC+3, ο χρήστης acm έγραψε:


On Tue, May 24, 2016 at 5:36 AM, Apostolos T <apts...@gmail.com> wrote:
Hi,

I am trying to build the C++ driver following the instructions provided here: https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-%28New-Driver%29

Unfortunately I am experiencing a few issues.

The information of my setup is as follows: 
  • The version of the driver you are trying to build (branch or tag).
    • Mongo C++ Driver
  • Host OS, version, and architecture.
    • Windows 7 Pro 64bit
  • C++ Compiler and version.
    • MSVC 2015 Community Update 2 (version 14.0.25123.00)
  • Cmake version.
    • 3.5.2
Thanks for providing this, it is very helpful.

 
According to your new driver guide there doesn't seem to be any need for the PKG CONFIG tool and instructions on how the installation could be done in a Windows environment.

If you don't have pkgconfig on Windows (and I think it is pretty unusual to have it), you will need to explicitly tell the C++11 driver CMake where to find libbson and libmongoc by setting the LIBBSON_DIR and LIBMONGOC_DIR variables explicitly.

It would be better if the C driver installed CMake Find modules, but it currently does not (see https://jira.mongodb.org/browse/CDRIVER-1058)

 
I successfully built the latest MongoDB C driver version from github, and I tried to use a similar approach for the c++ driver.

Can you please provide instructions for building in a windows environment and whether the PKG Config tool is needed or not? 

Per the above, you need to set LIBBSON_DIR and LIBMONGOC_DIR. Please have a look at our AppVeyor configuration for examples:



By running the following command ( according to the guidelines you provided) I was able to build the mongo-cxx-driver projects:

-          ...\mongo-cxx-driver>cmake.exe -G "Visual Studio 14 2015 Win64" "-DLIBBSON_DIR=C:\mongo-c-driver" "-DLIBMONGOC_DIR=C:\mongo-c-driver" "-DBOOST_ROOT=PATH\BOOST_1.56" "-DBOOST_INCLUDEDIR=PATH\BOOST_1.56" "-DCMAKE_BUILD_TYPE = Release" "-DCMAKE_INSTALL_PREFIX = c:\mongo-cxx-driver"

and then I ran ALL_BUILD.vcxproj & INSTALL.vcxproj through the VS2015.




Also, after a few efforts I saw in the CMakeLists.txt that for the case of Visual Studio there is a version condition:

"...elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
       if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506")
          message(FATAL_ERROR "Insufficient Microsoft Visual C++ version - MSVC 2015 Update 1+ required") ... "

while the current version of VS2015 Community Update 2 is 14.0.25123.00.

This is checking the vesrion of Visual C++, not Visual Studio:


I'm reasonably sure that this check is correct? Is it actually issuing the fatal error? Do you have more than one version of Visual C++ installed on this system? How are you specifying which one to use? Are you running inside the configured terminal for one of the VC installs?

The version I provided for VS wasn't to compare with the MSVC but to express my reasoning as to why did I have issues with the latest version of MS Visual Studio since all MSVC components should be included. It seems that the Visual C++ components aren't included after all in the default installation of the MSVS 2015 community edition, so I had to modify the installation.


Thanks,
Andrew

Finally, another think that should be mentioned to the Wiki (regarding the new driver) is the need for the BOOST library and specifically above v1.56.

Thank you again for the prompt reply and the valuable info.

Best Regards,
Apostolos

Andrew Morrow

unread,
May 26, 2016, 9:22:23 AM5/26/16
to mongod...@googlegroups.com


By running the following command ( according to the guidelines you provided) I was able to build the mongo-cxx-driver projects:

-          ...\mongo-cxx-driver>cmake.exe -G "Visual Studio 14 2015 Win64" "-DLIBBSON_DIR=C:\mongo-c-driver" "-DLIBMONGOC_DIR=C:\mongo-c-driver" "-DBOOST_ROOT=PATH\BOOST_1.56" "-DBOOST_INCLUDEDIR=PATH\BOOST_1.56" "-DCMAKE_BUILD_TYPE = Release" "-DCMAKE_INSTALL_PREFIX = c:\mongo-cxx-driver"

and then I ran ALL_BUILD.vcxproj & INSTALL.vcxproj through the VS2015.

That looks good. I'm happy to hear it is working for you now.

 

Finally, another think that should be mentioned to the Wiki (regarding the new driver) is the need for the BOOST library and specifically above v1.56.

I've added a new section to the wiki instructions that indicates this. Thanks for the suggestion.

Thanks,
Andrew
Reply all
Reply to author
Forward
0 new messages