本文介绍了使用mongodb构建C ++项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将度量保存在mongoDB文档中,并在以后的操作中使用此数据.

我已按照Joyo Waseem的添加源代码

  #include< cstdint>#include< iostream>#include< vector>#include< bsoncxx/json.hpp>#include< mongocxx/client.hpp>#include< mongocxx/stdx.hpp>#include< mongocxx/uri.hpp>使用bsoncxx :: builder :: stream :: close_array;使用bsoncxx :: builder :: stream :: close_document;使用bsoncxx :: builder :: stream :: document;使用bsoncxx :: builder :: stream :: finalize;使用bsoncxx :: builder :: stream :: open_array;使用bsoncxx :: builder :: stream :: open_document;int main(){mongocxx :: client mongo_client {mongocxx :: uri {"mongodb://localhost:27017"}};返回0;} 

构建解决方案

  1> ----------构建开始:项目:mongodb,配置:调试Win32 ------1> Source.cpp1> mongodb.vcxproj->D:\ dev \ cpptest \ mongodb \ Debug \ mongodb.exe==========构建:1成功,0失败,0最新,跳过0 ========== 

要运行.exe,您需要在路径中添加D:\ dev \ GitHub \ vcpkg \ installed \ x86-windows \ bin.这样,.exe才能找到mongocxx.dll

I want to save measurements in a mongoDB document and use this data in further operations.

I have followed the steps described in this comment by Joyo Waseem to install the needed driver.However, I still get several Error Messages (82 to be specific) in some of the files (alignment_of.hpp; is_nothrow_move_assignable.hpp; view_or_value.hpp; types.hpp; etc). These are just some files which create an error.

The error-messages are:

I don‘t know if I have done something wrong/skipt something that is considered as an unspoken standard or if some parts of the software are incompatible.Just to make sure, if I have used vcpkg to install the drivers, do I still need to include some directories in the properties? Like for example the additional-Include Directory? Is there also a difference between using vcpkg and cmake?

Thanks for your help in advance.

解决方案

It is a bit unclear from your question what your code is doing. I will include an example on how to build the sample code below.vcpkg is a packaging manager and cmake is a build tool.

Setup vcpkg in a command prompt:

cd vcpkg
bootstrap-vcpkg.bat
vcpkg install mongo-cxx-driver

Setup a Visual Studio project
Add source code

#include <cstdint>
#include <iostream>
#include <vector>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/uri.hpp>

using bsoncxx::builder::stream::close_array;
using bsoncxx::builder::stream::close_document;
using bsoncxx::builder::stream::document;
using bsoncxx::builder::stream::finalize;
using bsoncxx::builder::stream::open_array;
using bsoncxx::builder::stream::open_document;

int main() {
    mongocxx::client mongo_client{ mongocxx::uri{"mongodb://localhost:27017"} };
    return 0;
}

Build Solution

1>------ Build started: Project: mongodb, Configuration: Debug Win32 ------
1>Source.cpp
1>mongodb.vcxproj -> D:\dev\cpptest\mongodb\Debug\mongodb.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

The to run the .exe you need to add D:\dev\GitHub\vcpkg\installed\x86-windows\bin to the path. This is so that the .exe can find the mongocxx.dll

这篇关于使用mongodb构建C ++项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:27