Problem building mongo-cxx-driver v3.6 on Windows

Hi,

I am having a problem building the mongo-cxx driver on Windows.
I would upload the cmake error and output logs but the forum will not allow me to.

Any assistance would be greatly appreciated.

Regards.
Dave Dutton

>cmake -G "Visual Studio 16 2019" -A "x64"  -DBUILD_VERSION=3.6  -DBOOST_ROOT=F:\Projects\BuildTools\boost-1_73_0  -DCMAKE_CXX_STANDARD=17  -DCMAKE_CXX_FLAGS="/Zc:__cplusplus"  -DCMAKE_PREFIX_PATH=F:\Projects\BuildTools\mongo-driver-3.6\mongo-c-driver-1.18.0  -DCMAKE_INSTALL_PREFIX=F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6  ..
-- The CXX compiler identification is MSVC 19.29.30038.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No build type selected, default is Release
-- The C compiler identification is MSVC 19.29.30038.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at cmake/ParseVersion.cmake:17 (list):
  list index: 2 out of range (-2, 1)
Call Stack (most recent call first):
  src/bsoncxx/CMakeLists.txt:17 (ParseVersion)


-- Auto-configuring bsoncxx to use C++17 std library polyfills since C++17 is active and user didn't specify otherwise
bsoncxx version: 3.6.
found libbson version 1.18.0
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
CMake Error at cmake/ParseVersion.cmake:17 (list):
  list index: 2 out of range (-2, 1)
Call Stack (most recent call first):
  src/mongocxx/CMakeLists.txt:17 (ParseVersion)


mongocxx version: 3.6.
found libmongoc version 1.18.0
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Build files generated for:
--      build system: Visual Studio 16 2019
--      instance: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional
--      instance: x64
-- Configuring incomplete, errors occurred!
See also "F:/Projects/BuildTools/mongo-driver-3.6/mongo-cxx-driver-releases-v3.6/cmake-build/CMakeFiles/CMakeOutput.log".
See also "F:/Projects/BuildTools/mongo-driver-3.6/mongo-cxx-driver-releases-v3.6/cmake-build/CMakeFiles/CMakeError.log".

Here is the content of CMakeError.log:

Performing C++ SOURCE FILE Test COMPILER_HAS_DEPRECATED_ATTR failed with the following output:
Change Dir: F:/Projects/BuildTools/mongo-driver-3.6/mongo-cxx-driver-releases-v3.6/cmake-build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe cmTC_2345d.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.



  Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30038.1 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  src.cxx

  cl /c /Zi /W1 /WX- /diagnostics:column /Od /Ob0 /D COMPILER_HAS_DEPRECATED_ATTR /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_2345d.dir\Debug\\" /Fd"cmTC_2345d.dir\Debug\vc142.pdb" /external:env:EXTERNAL_INCLUDE /external:W1 /Gd /TP /errorReport:queue  /Zc:__cplusplus "F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\src.cxx"

F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\src.cxx(1,16): error C2065: '__deprecated__': undeclared identifier [F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\cmTC_2345d.vcxproj]

F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\src.cxx(1,31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\cmTC_2345d.vcxproj]

F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\src.cxx(1,33): error C2062: type 'int' unexpected [F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\cmTC_2345d.vcxproj]

F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\src.cxx(1,48): error C2143: syntax error: missing ';' before '{' [F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\cmTC_2345d.vcxproj]

F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\src.cxx(1,48): error C2447: '{': missing function header (old-style formal list?) [F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\cmTC_2345d.vcxproj]

F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\src.cxx(2,25): error C3861: 'somefunc': identifier not found [F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\cmTC_2345d.vcxproj]



Source file was:
__attribute__((__deprecated__)) int somefunc() { return 0; }
    int main() { return somefunc();}
Determining if the include file pthread.h exists failed with the following output:
Change Dir: F:/Projects/BuildTools/mongo-driver-3.6/mongo-cxx-driver-releases-v3.6/cmake-build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe cmTC_d9d46.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.



  Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30038.1 for x64

  Copyright (C) Microsoft Corporation.  All rights reserved.

  CheckIncludeFile.cxx

  cl /c /Zi /W1 /WX- /diagnostics:column /Od /Ob0 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_d9d46.dir\Debug\\" /Fd"cmTC_d9d46.dir\Debug\vc142.pdb" /external:env:EXTERNAL_INCLUDE /external:W1 /Gv /TP /errorReport:queue  /Zc:__cplusplus "F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\CheckIncludeFile.cxx"

F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\CheckIncludeFile.cxx(1,10): fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory [F:\Projects\BuildTools\mongo-driver-3.6\mongo-cxx-driver-releases-v3.6\cmake-build\CMakeFiles\CMakeTmp\cmTC_d9d46.vcxproj]

@Dave_Dutton the MongoDB drivers use SEMVER, so the version you specify to CMake with -DBUILD_VERSION= needs to include three numeric parts separated by two dots.

1 Like

@Roberto_Sanchez that fixed it. Thanks!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.