[SERVER-29511] MongoDB failed to build due to error C2512: 'boost::unordered::unordered_set<mongo::LogicalSessionId,mongo::LogicalSessionId::Hash,std::equal_to<T>,std::allocator<T>>': no appropriate default constructor available Created: 08/Jun/17  Updated: 30/Oct/23  Resolved: 12/Jun/17

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: 3.5.9

Type: Bug Priority: Critical - P2
Reporter: KarenHuang [X] Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File mongodb_x64_build.log    
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

*Environment: *
Windows Sever 2012 R2 + VS2015 Update 3 + MongoDB master branch latest revision

Reproduce steps:
1. git clone -c core.autocrlf=true https://github.com/mongodb/mongo D:\MongoDB\src
2. Open a VS 2015 x64 command prompt and browse to D:\MongoDB\src
3. pip.exe install -r .\buildscripts\requirements.txt
4. scons all -j4

Acutal result:
src\mongo\db\logical_session_cache_test.cpp(247): error C2512: 'boost::unordered::unordered_set<mongo::LogicalSessionId,mongo::LogicalSessionId::Hash,std::equal_to<T>,std::allocator<T>>': no appropriate default constructor available
with
[
T=mongo::LogicalSessionId
]
src\mongo\db\logical_session_cache_test.cpp(247): note: Constructor for class 'boost::unordered::unordered_set<mongo::LogicalSessionId,mongo::LogicalSessionId::Hash,std::equal_to<T>,std::allocator<T>>' is declared 'explicit'
with
[
T=mongo::LogicalSessionId
]
scons: *** [build\opt\mongo\db\logical_session_cache_test.obj] Error 2

Participants:

 Description   

MongoDB failed to buid due to error C2512: 'boost::unordered::unordered_set<mongo::LogicalSessionId,mongo::LogicalSessionId::Hash,std::equal_to<T>,std::allocator<T>>': no appropriate default constructor available. This issue is caused by revision 4c3337ahttps://github.com/mongodb/mongo/commit/4c3337abe512a37c8e4cb22e16eafcd04bc5bd3a Could you pleaes help to take a look at this? Thanks in advance!

Some investigate on my side:
The related code in logical_seesion_cache_test.cpp
stdx::promise<int> hitRefresh;
auto refreshFuture = hitRefresh.get_future();

// Advance time to first refresh point, check that refresh happens, and
// that it includes both our records
sessions()->setRefreshHook([&hitRefresh](LogicalSessionIdSet sessions) -> LogicalSessionIdSet {
hitRefresh.set_value(sessions.size());
return {};
});

If we change the code as below. There is no error reported.
stdx::promise<int> hitRefresh;*
to
stdx::promise<LogicalSessionId> hitRefresh;*



 Comments   
Comment by Mark Benvenuto [ 08/Jun/17 ]

Actually, this was caught by are internal continuous integration system with VS 2015. The "unknown compiler version" messages were unrelated.

The commit as been reverted:

https://github.com/mongodb/mongo/commit/12e54a966bde02389224b78db6500978ca68a54e

Comment by Andrew Morrow (Inactive) [ 08/Jun/17 ]

Also, is there a reason that you are building the master branch of MongoDB? It is under active development, so it will be found to be broken at times, and the resulting binaries should definitely not be used for production work. If you want to run MongoDB, it would be much better to download one of the pre-built packages from https://www.mongodb.com/download-center.

Comment by Mark Benvenuto [ 08/Jun/17 ]

I can only reproduce this error if I try compiling MongoDB with VS 2017 (which required several patches). It does not reproduce with VS 2015 Update 3.

Try running "python buildscripts\scons.py" instead of the install scons. The scons included in our source tree will never try to use VS 2017 at this time.

Comment by Eric Milkie [ 08/Jun/17 ]

From these messages in the log, they suggest you are not actually using VS 2015's compiler:

Unknown compiler version - please run the configure tests and report the results

This message is output by Boost headers when you are running a Visual Studio compiler that is newer than the ones it can detect – for example, this message appears when you are compiling with Visual Studio 2017.

Generated at Thu Feb 08 04:21:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.