Hey,
I am trying to build mongo-cxx-driver on windows and hitting some issues. Has anyone been able to build the latest release(r3.7.0)? I didn’t have an issue with r3.6.7.
The issue seems to be related with pollyfill but not sure what changed as yet.
Usually build with polyfill disabled but it seems in that case bsoncxx automatically enables polyfill.
01:50:38 -- Auto-configuring bsoncxx to use C++17 std library polyfills since C++17 is active and user didn't specify otherwise
01:50:38 bsoncxx version: 3.7.0
Which leads to this error
82>C:\conan\.conan\data\mongo-cxx-driver\3.7.0\nemtech\stable\package\ba80356c2e9b1444ad652db7a781f16d357b0c49\include\bsoncxx\v_noabi\bsoncxx/stdx/make_unique.hpp(66,1): fatal error C1189: #error: "Cannot find a valid polyfill for make_unique" [C:\tmp\_build\extensions\mongo\tests\test\tests.catapult.test.mongo.vcxproj]
Thanks @Rishabh_Bisht for the quick reply.
When I build with using your cmake command, tests are failing to build with the error below.
Can you tell me which VS development env are you using?
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="/Zc:__cplusplus" -DCMAKE_PREFIX_PATH=C:\mongo-c-driver -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ..
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- The CXX compiler identification is MSVC 19.34.31933.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/Python310/python.exe (found version "3.10.3")
C:\Users\wayon\code\wayonb\monorepo\client\catapult\_deps\source\mongo-cxx-driver\etc\calc_release_version.py:29: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.version import LooseVersion
-- No build type selected, default is Release
-- The C compiler identification is MSVC 19.34.31933.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Auto-configuring bsoncxx to use C++17 std library polyfills since C++17 is active and user didn't specify otherwise
bsoncxx version: 3.7.0
found libbson version 1.23.1
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
mongocxx version: 3.7.0
found libmongoc version 1.23.1
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Build files generated for:
-- build system: Visual Studio 17 2022
-- instance: C:/Program Files/Microsoft Visual Studio/2022/Community
-- instance: x64
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/wayon/code/wayonb/monorepo/client/catapult/_deps/source/mongo-cxx-driver/_build
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\ostream(305,1): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\wayon\code\wayonb\monorepo\client\catapu
lt\_deps\source\mongo-cxx-driver\_build\src\bsoncxx\test\test_bson.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\ostream(298,1): message : while compiling class template member function 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_trai
ts<char>>::operator <<(unsigned int)' [C:\Users\wayon\code\wayonb\monorepo\client\catapult\_deps\source\mongo-cxx-driver\_build\src\bsoncxx\test\test_bson.vcxproj]
C:\Users\wayon\code\wayonb\monorepo\client\catapult\_deps\source\mongo-cxx-driver\src\bsoncxx/test_util/to_string.hh(53,57): message : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostrea
m<char,std::char_traits<char>>::operator <<(unsigned int)' being compiled [C:\Users\wayon\code\wayonb\monorepo\client\catapult\_deps\source\mongo-cxx-driver\_build\src\bsoncxx\test\test_bson.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\ostream(671,75): message : see reference to class template instantiation 'std::basic_ostream<char,std::char_traits<char>>' being compiled [C:\Users\wayon\code\wa
yonb\monorepo\client\catapult\_deps\source\mongo-cxx-driver\_build\src\bsoncxx\test\test_bson.vcxproj]
Generating Code...
C:\Users\wayon\code\wayonb\monorepo\client\catapult\_deps\source\mongo-cxx-driver\src\bsoncxx\test\bson_builder.cpp(1705): fatal error C1001: Internal compiler error. [C:\Users\wayon\code\wayonb\monorepo\client\catapult\_deps\source\mongo-cxx-driver\
_build\src\bsoncxx\test\test_bson.vcxproj]
(compiler file 'D:\a\_work\1\s\src\vctools\Compiler\Utc\src\p2\main.c', line 224)
To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Building Custom Rule C:/Users/wayon/code/wayonb/monorepo/client/catapult/_deps/source/mongo-cxx-driver/src/mongocxx/test/CMakeLists.txt
client_helpers.cpp
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\ostream(482,1): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\wayon\code\wayonb\monorepo\client\catapu
lt\_deps\source\mongo-cxx-driver\_build\src\mongocxx\test\test_client_side_encryption_specs.vcxproj]
Looking at the last logs it would seem like the build succeed. The only reason checked for an error cause cmake exited with error code of 1 and my script will stop on error.
An internal compiler error is an issue with the compiler, not sure what we can do here. But I’d be happy to raise a ticket with our engineering team to get this investigated more thoroughly.
In the meantime, try commenting the test that’s causing this issue, unless you need the tests as well.
I am more curious of why you are not seeing this error. I have built with Windows 11 and Windows Server 2022 with both VS 2019 and VS 2022 and always get this error. Thinking I am missing something in my environment but not sure what.
Upon a deeper look, I found out I wasn’t building tests. I come across similar error as yours when building tests. This needs investigation.
For polyfill question Auto-configuring bsoncxx to use C++17 std library polyfills since C++17 is active and user didn't specify otherwise means the C++17 standard library features are used to satisfy the C++17 polyfill. This is expected. It is enabled when -DCMAKE_CXX_STANDARD=17 flag is set.
Thanks @Rishabh_Bisht, glad you were able to repo the issue when build tests.
Pollyfill question
Yes, I saw the cmake file and BSONCXX_POLY_USE_STD is defined in this case.
The issue seems to be that for make_unique, this define is not used to include the STD header. maybe something is missing?
When trying to build I am getting the error below bsoncxx/stdx/make_unique.hpp(66,1): fatal error C1189: #error: "Cannot find a valid polyfill for make_unique"