[CDRIVER-3558] Installation docs for Windows should include explicit configuration Created: 28/Feb/20  Updated: 28/Oct/23  Resolved: 11/Mar/20

Status: Closed
Project: C Driver
Component/s: docs
Affects Version/s: None
Fix Version/s: 1.17.0-beta, 1.17.0

Type: Bug Priority: Major - P3
Reporter: shijie Jiang Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

visual studio 2017 win10 x64


Attachments: PNG File error.png     PNG File screenshot-1.png    
Issue Links:
Related
related to CXX-1961 WINDOWS | Release build, bad alloc ex... Closed

 Description   

Critical error detected c0000374

......\mongo-c-driver-1.15.2\src\libmongoc\src\mongoc\mongoc-cursor.c:1110 _mongoc_cursor_collection(): precondition failed: *collection_len > 0



 Comments   
Comment by Githook User [ 11/Mar/20 ]

Author:

{'username': 'kevinAlbs', 'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com'}

Message: CDRIVER-3558 update install docs on Windows
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/745647e0932a913823a349a929f4b95a3e80d482

Comment by Kevin Albertson [ 07/Mar/20 ]

Glad to help! I've modified this ticket to update our documentation.

Comment by shijie Jiang [ 07/Mar/20 ]

Thank you very much! It works just as you said.

Comment by Kevin Albertson [ 05/Mar/20 ]

Hi jsjfbj@163.com, thanks for the additional info. The output of dumpbin.exe of libmongoc-1.0.dll does indicate it's linking against the debug runtime (VCRUNTIME140D.dll). I was able to reproduce that locally with VS 2019, but specifying an explicit configuration for the installation command worked:

Try installing with:

msbuild.exe /p:Configuration=Release INSTALL.vcxproj

I believe that is an omission in our documentation, as our installation instructions do no include the flag in the installation command: http://mongoc.org/libmongoc/current/installing.html#building-on-windows-with-visual-studio

Let me know if that works, and I'll update the documentation accordingly.

Comment by shijie Jiang [ 05/Mar/20 ]

// MongoDB C driver
cmake -G "Visual Studio 15 2017 Win64" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=C:\mongo-c-driver-Release" "-DCMAKE_PREFIX_PATH=C:\mongo-c-driver-Release" ..
msbuild.exe /p:Configuration=Release ALL_BUILD.vcxproj
msbuild.exe INSTALL.vcxproj

// MongoDB cxx driver
cmake.exe -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver-Release -DCMAKE_PREFIX_PATH=C:\mongo-c-driver-Release -DBOOST_ROOT=D:\MongoDBC\boost_1_71_0 ..
msbuild.exe /p:Configuration=Release ALL_BUILD.vcxproj
msbuild.exe INSTALL.vcxproj

The debug release driver compiled successfully. The debug version works fine,but the release version doesn't

// test code
#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/instance.hpp>
using namespace std;
using namespace bsoncxx;
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::make_document;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::open_document;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;

int main()
{
mongocxx::instance inst{};
mongocxx::client mgdb_connect(mongocxx::uri{ "mongodb://FZJC:xxxx@127.0.0.1:27017/xxxx" });  // By default, a session is causally consistent.    // Pass options::client_session to override causal consistency.
auto session = mgdb_connect.start_session();        //
mongocxx::collection coll_dat_fmt = mgdb_connect["gkaq_db"]["datFormat"];
mongocxx::cursor cursor = coll_dat_fmt.find(session, {});
for (auto doc : cursor)

{ std::cout << bsoncxx::to_json(doc) << "\n"; }

    std::cout << "Hello World!\n"; 
}

 

Comment by Kevin Albertson [ 02/Mar/20 ]

Hi jsjfbj@163.com, thank you for the report! To diagnose and reproduce the issue, we may need more information.

  • Can you include the cmake command (and the output) you are using to build the C and C++ drivers?
  • It's possible the C++ driver, C driver, and your application may be linked to different forms of Windows runtime libraries, causing the crash. It may be helpful to inspect the output of dumpbin.exe to check that your application, the C driver, and C++ driver, all use the same CRT. E.g. Using the native tools command prompt for libmongoc:

    dumpbin.exe /DEPENDENTS libmongoc-1.0.dll
    

  • If there is relevant code outside of the screenshot, can you include a code snippet to reproduce? Ideally a short, self-contained, compilable example (http://sscce.org/)
Generated at Wed Feb 07 21:18:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.