0

I have build the mongodb cxx binaries in windows following the steps described here.

I have created the Test application as mentioned in the steps. On release builds, the application throws bad allocation exception: std::bad_alloc at memory location 0x0047EB60] in this line :

mongocxx::uri muri{ uri_string }; 

The same code works with Debug build.

Could someone please help me to fix the issue in Release build ?

Vincent
  • 3,656
  • 1
  • 23
  • 32
snb
  • 633
  • 1
  • 6
  • 13
  • Can you provide a stack trace of when the error occurs using Visual Studio's debugger? – Saghm Jul 03 '17 at 20:45
  • My issue got resolved after I built mongocxx and bsoncxx in Release and used that Thanks for the support – snb Jul 04 '17 at 07:53
  • Stack trace: vcruntime140d.dll!59aa4970() Unknown [Frames below may be incorrect and/or missing, no symbols loaded for vcruntime140d.dll] [External Code] > bsoncxx.dll!boost::basic_string_ref >::to_string() Line 113 C++ bsoncxx.dll!bsoncxx::v_noabi::string::view_or_value::terminated() Line 27 C++ mongocxx.dll!573b5124() Unknown – snb Jul 04 '17 at 07:55
  • Awesome! Just to make sure, this stacktrace is from before you fixed the issue, right? – Saghm Jul 05 '17 at 16:10

1 Answers1

3

My issue got resolved after I built mongocxx and bsoncxx in Release and used that. Previously I built those in Debug and Test Application in release. Need to match the target configuration.

snb
  • 633
  • 1
  • 6
  • 13
  • Build LIBSON in 64 : cmake -G "Visual Studio 14 2015 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" – snb Aug 03 '17 at 07:22
  • C Driver in 64: cmake -G "Visual Studio 14 2015 Win64" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver" "-DBSON_ROOT_DIR=C:\mongo-c-driver" – snb Aug 03 '17 at 07:23
  • Cxx Driver : cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver -DCMAKE_PREFIX_PATH=c:\mongo-c-driver -DBOOST_ROOT=C:\boost_1_64_0 -DLIBBSON_DIR=c:\mongo-c-driver -DLIBMONGOC_DIR=c:\mongo-c-driver Win64 : optional and should be same as c driver – snb Aug 03 '17 at 07:24