[CXX-1286] building mongodbcxx on Windows Created: 24/Mar/17  Updated: 06/Apr/17  Resolved: 06/Apr/17

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Seungwon Yoon Assignee: J Rassi
Resolution: Done Votes: 0
Labels: Bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10, MSVS 2015 Update 3, mongodbcxx master branch
boost 1.63.0


Attachments: Text File ALLBUILD_output.txt     Zip Archive build.zip     Text File cmake_compile_output.txt     Text File cmake_output.txt     Text File error_msg.txt     File experiment.diff     File mongocxx.vcxproj     Text File msbuild_version.txt    
Issue Links:
Duplicate
duplicates CXX-1012 Driver fail to compile on windows wit... Closed
is duplicated by CXX-1295 Provide clearer error message to user... Backlog
is duplicated by CXX-1256 Fix CI builds with libmongoc master b... Closed

 Description   

I installed mongodbcxx using following command

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local "-DLIBBSON_DIR=C:/mongo-c-driver/" "-DLIBMONGOC_DIR=C:/mongo-c-driver/" "-DBOOST_ROOT:PATH=C:\Program Files\boost\boost_1_63_0" "-DBSONCXX_POLY_USE_BOOST=1" ..

Then I did msbuild.exe ALL_BUILD.vcxproj to build the MSVS project file which resulted in 327 errors.

One of errors was

src\mongocxx/test_util/mock.hh(173): error C3861: 'assert': identifier not found

so I added #include <assert.h> to mock.hh and errors were reduced down to 80.

The rest has to do with bsoncxx and I was wondering if I could get any help.

Attached the command prompt error message as txt file



 Comments   
Comment by J Rassi [ 06/Apr/17 ]

ysw0927: nope, I'll close this ticket now. Glad you were able to successfully build the driver!

The information and logs you've provided already were quite helpful, thank you. I've filed CXX-1295 to improve the user experience when running CMake with the wrong generator on Windows.

Comment by David Golden [ 06/Apr/17 ]

The "assert" problem looks like a duplicate of CXX-1256 caused by building against libmongoc from its master branch.

Comment by Seungwon Yoon [ 06/Apr/17 ]

My apology, something else had me caught up for last several days.

Same thing from above, I was getting this error:

src\mongocxx/test_util/mock.hh(173): error C3861: 'assert': identifier not found

So I added #include <assert.h> for mock.hh and yes, I was finally able to build the driver successfully.

I appreciate your help. Do you want me to post anything else before the ticket gets closed?

Comment by J Rassi [ 06/Apr/17 ]

Hi ysw0927, just following up on this ticket. Were you able to build the driver successfully build after compiling from a clean build directory?

Comment by J Rassi [ 03/Apr/17 ]

Hmm, the vcxproj files from the build.zip archive you uploaded now look correct: the ClCompile sections now say "<ExceptionHandling>Sync</ExceptionHandling>" instead of "<ExceptionHandling></ExceptionHandling>".

Can you re-try a full build from this build directory, with "MSBuild.exe ALL_BUILD.vcxproj"? If this works now, then I wonder if the issue was just that some data in the CMake cache (like CMAKE_CXX_FLAGS, which is now "/DWIN32 /D_WINDOWS /W3 /GR /EHsc" as expected) was out-of-date after you switched CMake generators, and that clearing this cached data was the necessary fix.

Comment by Seungwon Yoon [ 02/Apr/17 ]

For cmake, I just downloaded MSI from the website.

Here is the command that I ran from C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build:

cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local "-DLIBBSON_DIR=C:/mongo-c-driver/" "-DLIBMONGOC_DIR=C:/mongo-c-driver/" "-DBOOST_ROOT:PATH=C:\Program Files\boost\boost_1_63_0" "-DBSONCXX_POLY_USE_BOOST=1" ..

Attached the output as cmake_compile_output.txt as well as .zip of build folder.

It looks like we work in different time zones but I appreciate that you keep in touch.

Comment by J Rassi [ 31/Mar/17 ]

Indeed, I can confirm your CMake-generated vcxproj file has "<ExceptionHandling></ExceptionHandling>" directives, whereas I'd expect them to have "<ExceptionHandling>Sync</ExceptionHandling>" directives. There's a couple of other suspicious things about the vcxproj file, too: I notice that it doesn't list "WIN32" or "_WINDOWS" in the "PreprocessorDefinitions" directive, for example.

Thanks also for the CMake version information. I'm unable to reproduce with the same version, so it has to be something else.

I have two more requests for information:

  • How did you install CMake? Did you install the binaries/MSI from https://cmake.org/download/, or did you compile CMake from source?
  • Please delete the directory "C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build", re-create it, and re-run cmake as you normally do. Then:
    • Re-post the exact command line line you passed to the cmake binary, and re-post the entire output of running the command.
    • Without running MSBuild, please zip or tar the entire contents of the build\ directory and upload it as an attachment. I expect it to be <10MB in size. I'm particularly interested in looking at the cmake logs in the build\CMakeFiles\ for clues.

Thanks for your patience!

Comment by Seungwon Yoon [ 31/Mar/17 ]

Thanks for the help.

I uploaded mongocxx.vcxproj and this is the cmake verision:

C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build>cmake --version
cmake version 3.8.0-rc2
 
CMake suite maintained and supported by Kitware (kitware.com/cmake).

Comment by J Rassi [ 31/Mar/17 ]

Actually, nevermind my question above. I realize that the build output you posted describes the issue in a warning when compiling that source file: "warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc". Indeed, I can reproduce this issue when I manually remove /EHsc from my compile line. I generally would expect CMake's Visual Studio generator to generate an <ExceptionHanding> block for the relevant project file that translates into /EHsc on the compile line, though.

Could you upload C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx.vcxproj as an attachment to this ticket? And also post the output of running "cmake --version"? Thanks.

Comment by J Rassi [ 31/Mar/17 ]

Thanks for the additional information. Could you please download the attached patch "experiment.diff", apply the patch with "git apply experiment.diff", attempt to compile again, and paste in the new set of errors? The patch adds some additional static assertions, and the results will hopefully will shed light on whether the issue is with mongocxx, Boost, MSVC, or something else.

Comment by Seungwon Yoon [ 30/Mar/17 ]

Added output of cmake, output of ALL_BUILD, and version of msbuild.exe.

Also I tried CL.exe but It's not a recognized command.

Comment by J Rassi [ 28/Mar/17 ]

Hmm. It appears that your compiler evaluates std::is_nothrow_move_constructible<T>::value to false for the model types, which is unexpected. I attempted to reproduce this issue with VS2015 Update 3 and Boost 1.63, but the issue did not reproduce for me.

I'll need additional information to help further the diagnosis of your problem. Could you please post:

  • The complete output of cmake.
  • The complete output of MSBuild.exe. Assuming it's long, please upload it as an attachment to this ticket. I'm specifically looking for the complete command line passed to CL.exe that was used to compile write.cpp.
  • The output of running "MSBuild.exe /version" and "CL.exe" (no options).

Thanks.

Comment by Seungwon Yoon [ 28/Mar/17 ]

Thanks for that solution. It got rid of the errors I mentioned above but now I am getting different errors.

"C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx.vcxproj" (default target) (5) ->
(ClCompile target) ->
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(32): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(33): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(42): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(43): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx.vcxproj]
 
 
"C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj" (default target) (6) ->
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(32): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(33): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(37): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(38): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(42): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(43): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(47): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(48): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(52): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(53): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_mocked.vcxproj]
 
 
"C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj" (default target) (7) ->
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(32): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(33): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(37): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(38): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(42): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(43): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(47): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(48): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(52): error C2338: Move-construct may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
  C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\src\mongocxx\model\write.cpp(53): error C2338: Move-assign may throw [C:\Users\SynchroGrid\Desktop\mongo-cxx-driver-releases-stable\build\src\mongocxx\mongocxx_static.vcxproj]
 
    319 Warning(s)
    24 Error(s)
 
Time Elapsed 00:03:01.27

It's same type of error from this issue

The reporter in that case was able to fix by updating boost library but I already have boost 1.63.0 which is the latest version.

What could possibly cause this in my case?

Following is the command I used for compilation:

cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local "-DLIBBSON_DIR=C:/mongo-c-driver/" "-DLIBMONGOC_DIR=C:/mongo-c-driver/" "-DBOOST_ROOT:PATH=C:\Program Files\boost\boost_1_63_0" "-DBSONCXX_POLY_USE_BOOST=1" ..

Comment by J Rassi [ 26/Mar/17 ]

Hi there. Sorry to hear you're having trouble building mongocxx.

I noticed this warning in your build output: "warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86'". This makes me suspect that you have an x64 libmongoc, but the linker is expecting to find an X86 library providing libmongoc symbols. Could you try adding -G "Visual Studio 14 2015 Win64" to your cmake invocation, and perform a clean build? The default generator for cmake on Windows will often be Visual Studio 14 2015 (without the "Win64"), which generates X86 output by default.

Generated at Wed Feb 07 22:02:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.