Создайте проект на C ++ с помощью mongodb - PullRequest
0 голосов
/ 08 декабря 2018

Я хочу сохранить измерения в документе mongoDB и использовать эти данные в дальнейших операциях.

Я выполнил шаги, описанные в этом комментарии Джойо Васима, чтобы установить необходимый драйвер.Тем не менее, я все еще получаю несколько сообщений об ошибках (в частности, 82) в некоторых файлах (alignment_of.hpp; is_nothrow_move_assignable.hpp; view_or_value.hpp; types.hpp; и т. Д.).Это только некоторые файлы, которые создают ошибку.

Сообщения об ошибках:

Severity Code Line Description Error (active) E0243 36 class or struct definition is missing Error (active) E1574 29 static assertion failed with "Arguments to is_nothrow_move_constructible must be complete types" Error (active) E0070 31 incomplete type is not allowed Error (active) E1574 31 static assertion failed with "Arguments to is_nothrow_move_assignable must be complete types" Error (active) E0262 36 not a class or struct name Error (active) E1018 36 namespace "bsoncxx" has no member class "view_or_value" Error (active) E0070 41 incomplete type is not allowed Error (active) E0276 41 name followed by '::' must be a class or namespace name Error (active) E0260 48 explicit type is missing ('int' assumed) Error (active) E0135 48 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 48 expected a ';' Error (active) E0276 56 name followed by '::' must be a class or namespace name Error (active) E0260 63 explicit type is missing ('int' assumed) Error (active) E0135 63 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 63 expected a ';' Error (active) E0070 64 incomplete type is not allowed Error (active) E0276 72 name followed by '::' must be a class or namespace name Error (active) E0260 79 explicit type is missing ('int' assumed) Error (active) E0135 79 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 79 expected a ';' Error (active) E0145 86 member "bsoncxx::v_noabi::types::b_double::type_id" may not be initialized Error (active) E0276 87 name followed by '::' must be a class or namespace name Error (active) E0260 94 explicit type is missing ('int' assumed) Error (active) E0135 94 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 94 expected a ';' Error (active) E0276 102 name followed by '::' must be a class or namespace name Error (active) E0106 105 invalid type for a bit field Error (active) E0040 105 expected an identifier Error (active) E0260 109 explicit type is missing ('int' assumed) Error (active) E0135 109 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 109 expected a ';' Error (active) E0145 111 member "bsoncxx::v_noabi::types::b_utf8::type_id" may not be initialized Error (active) E0106 114 invalid type for a bit field Error (active) E0040 114 expected an identifier Error (active) E0260 124 explicit type is missing ('int' assumed) Error (active) E0135 124 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 124 expected a ';' Error (active) E0077 127 this declaration has no storage class or type specifier Error (active) E0135 127 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 127 expected a ';' Error (active) E0077 128 this declaration has no storage class or type specifier Error (active) E0135 128 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 128 expected a ';' Error (active) E0077 129 this declaration has no storage class or type specifier Error (active) E0135 129 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 129 expected a ';' Error (active) E0077 130 this declaration has no storage class or type specifier Error (active) E0135 130 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 130 expected a ';' Error (active) E0077 131 this declaration has no storage class or type specifier Error (active) E0135 131 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 131 expected a ';' Error (active) E0077 132 this declaration has no storage class or type specifier Error (active) E0135 132 namespace "mongocxx::v_noabi::stdx" has no member "optional" Error (active) E0065 132 expected a ';' Error (active) E0145 149 member "bsoncxx::v_noabi::types::b_document::type_id" may not be initialized Error (active) E0145 181 member "bsoncxx::v_noabi::types::b_array::type_id" may not be initialized Error (active) E0106 181 invalid type for a bit field Error (active) E0018 181 expected a ')' Error (active) E0106 190 invalid type for a bit field Error (active) E0040 190 expected an identifier Error (active) E0145 206 member "bsoncxx::v_noabi::types::b_binary::type_id" may not be initialized Error (active) E0145 230 member "bsoncxx::v_noabi::types::b_undefined::type_id" may not be initialized Error (active) E0145 246 member "bsoncxx::v_noabi::types::b_oid::type_id" may not be initialized Error (active) E0106 262 invalid type for a bit field Error (active) E0018 262 expected a ')' Error (active) E0145 264 member "bsoncxx::v_noabi::types::b_bool::type_id" may not be initialized Error (active) E0106 271 invalid type for a bit field Error (active) E0040 271 expected an identifier Error (active) E0145 289 member "bsoncxx::v_noabi::types::b_date::type_id" may not be initialized Error (active) E0145 350 member "bsoncxx::v_noabi::types::b_null::type_id" may not be initialized Error (active) E0145 366 member "bsoncxx::v_noabi::types::b_regex::type_id" may not be initialized Error (active) E0145 402 member "bsoncxx::v_noabi::types::b_dbpointer::type_id" may not be initialized Error (active) E0145 421 member "bsoncxx::v_noabi::types::b_code::type_id" may not be initialized Error (active) E0145 462 member "bsoncxx::v_noabi::types::b_symbol::type_id" may not be initialized Error (active) E0145 500 member "bsoncxx::v_noabi::types::b_codewscope::type_id" may not be initialized Error (active) E0145 533 member "bsoncxx::v_noabi::types::b_int32::type_id" may not be initialized Error (active) E0145 562 member "bsoncxx::v_noabi::types::b_timestamp::type_id" may not be initialized Error (active) E0145 581 member "bsoncxx::v_noabi::types::b_int64::type_id" may not be initialized Error (active) E0145 606 member "bsoncxx::v_noabi::types::b_decimal128::type_id" may not be initialized Error (active) E0145 637 member "bsoncxx::v_noabi::types::b_minkey::type_id" may not be initialized Error (active) E0145 653 member "bsoncxx::v_noabi::types::b_maxkey::type_id" may not be initialized

Я не знаю, сделал ли я что-то неправильно / пропустил что-то, что считаетсякак невысказанный стандарт или если некоторые части программного обеспечения несовместимы.Просто чтобы убедиться, что если для установки драйверов я использовал vcpkg, нужно ли мне включать в каталог некоторые каталоги?Как, например, каталог дополнительных включений?Есть ли разница между использованием vcpkg и cmake?

Спасибо за вашу помощь заранее.

1 Ответ

0 голосов
/ 09 декабря 2018

Из вашего вопроса немного неясно, что делает ваш код.Ниже я приведу пример того, как создать пример кода.vcpkg - менеджер пакетов, а cmake - инструмент сборки.

Настройка vcpkg в командной строке:

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

Настройка проекта Visual Studio
enter image description here Добавить исходный код
enter image description here enter image description here

#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;
}

enter image description here

enter image description here

![enter image description here

enter image description here

Построение решения

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 ==========

Для запуска .exe вам нужно добавить в путь D: \ dev \ GitHub \ vcpkg \ instal \ x86-windows \ bin.Это так, что .exe может найти mongocxx.dll

enter image description here

...