如何使用mongodb的c++驱动程序构建程序?

时间:2021-04-14 03:03:45

Please tell me how to build a program using c++ driver of mongodb. No flames about my bad English.

请告诉我如何使用mongodb的c++驱动程序构建一个程序。我的英语很差。

My Environment

我的环境中

  • Windows7 64bit
  • Windows7多64位
  • Visual Studio Ultimate 2012 (x64 Release target project)
  • Visual Studio Ultimate 2012 (x64发布目标项目)

I performed the following steps.

我执行了以下步骤。

  • I installed Ptython 2.7.2, Python for Windows extensions and Scons 2.3.0.
  • 我安装了Ptython 2.7.2、用于Windows扩展的Python和Scons 2.3.0。
  • I installed boost 1.54.0. I perfomed 'boostrap' and 'b2 -a --build-type=complete --address-model=64 --link=static --runtime-link=static'
  • 我安装了提高1.54.0。我实现了'boostrap'和'b2 -a -build-type=complete -address-model=64 -link=静态-runtime-link=静态"
  • I download mongodb-linux-x86_64-v2.4-latest.tgz.
  • 我下载mongodb-linux-x86_64-v2.4-latest.tgz。
  • I added the following texts to SConstruct.

    我在SConstruct中加入了下面的文字。

    env.Append(CPPPATH=['C:\\boost\\boost_1_54_0'])
    env.Append(LIBPATH=['C:\\boost\\boost_1_54_0\\stage\\lib'])
    env.Append(CPPDEFINES=["_UNICODE"])
    env.Append(CPPDEFINES=["UNICODE"])
    
  • I performed 'scons mongoclient'.

    我执行您mongoclient”。

  • I made a project of Visual Studio C++.
  • 我做了一个Visual Studio c++的项目。
  • I set 'Release' and 'x64' in the project.
  • 我在项目中设置了“Release”和“x64”。
  • In Property pages/Configuration Properties/C C++/General/Additional Include Directories, I set 'C:\boost\boost_1_54_0' and 'C:\mongo\mongo-cxx-driver-v2.4\src'.
  • 在属性页/配置属性/C c++ /General/附加目录中,我设置了“C:\boost\boost_1_54_0”和“C:\mongo\ mongo-cxdriver -v2.4\src”。
  • In Property pages/Configuration Properties/Linker/General/Additional Library Directories, I set 'C:\boost\boost_1_54_0\stage\lib' and 'C:\mongo\mongo-cxx-driver-v2.4'.
  • 在属性页/配置属性/链接器/通用/附加库目录中,我设置了“C:\boost\boost_1_54_0\stage\lib”和“C:\mongo\mongo-cxx-driver-v2.4”。
  • In Property pages/Configuration Properties/Linker/Input/Additional Dependences, I set 'mongoclient.lib','ws2_32.lib' and 'psapi.lib'.
  • 在属性页/配置属性/链接器/输入/附加依赖项中,我设置了“mongoclient.lib”,“ws2_32”。*”和“psapi.lib”。
  • In Property pages/Configuration Properties/Linker/Input/Ignore Specific Default Libraries, I set 'msvcprt.lib' and 'LIBCMT.lib'.
  • 在属性页/配置属性/链接器/输入/忽略特定的默认库中,我设置了“msvcprt”。*”和“LIBCMT.lib”。
  • In Property pages/Configuration Properties/C C++/Preprosessor/Preprocessor Definitions, I set '_CRT_SECURE_NO_WARNINGS'.
  • 在属性页/配置属性/ c++ / preessor /Preprocessor定义中,我设置了“_CRT_SECURE_NO_WARNINGS”。
  • In Property pages/Configuration Properties/C C++/Code Generation/Runtime Library, I set 'Multi-threaded (/MT)'.
  • 在属性页/配置属性/ c++ /代码生成/运行时库中,我设置了“多线程(/MT)”。

I made a program using the driver. However, the build solution of the program has failed.

我用驱动程序做了一个程序。但是,该程序的构建解决方案失败了。

1>mongoclient.lib(stringutils.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>mongoclient.lib(initializer_dependency_graph.obj) : error LNK2001: unresolved external symbol __security_check_cookie
1>mongoclient.lib(initializer.obj) : error LNK2001: unresolved external symbol __security_check_cookie
....
 fatal error LNK1120: 154 unresolved externals

If would help me if you pointed out anything strange about the steps.

如果你能指出这些台阶有什么奇怪的地方,我将不胜感激。

Thank you.

谢谢你!

2 个解决方案

#1


9  

How to build MongoDB C++ driver

如何构建MongoDB c++驱动程序

This solution succeeded on a machine with the following characteristics:

该解决方案在一台具有以下特点的机器上获得成功:

  1. Windows XP SP3 32-bit
  2. Windows XP SP3 32位
  3. Visual Studio Express 2010 (VC 10)
  4. Visual Studio Express 2010 (vc10)

I used D:\MongoDBcplusplusClient as a working directory (I installed there all the prerequisites).

我使用了D:\ mongodbcplusplusplusclient作为工作目录(我在那里安装了所有的先决条件)。

Process:

过程:

  • Step 1
  • 步骤1

Download MongoDB C++ driver:

下载MongoDB c++司机:

https://github.com/mongodb/mongo-cxx-driver

https://github.com/mongodb/mongo-cxx-driver

You can make a clone using Git or download it as a .zip file (I did the second).You will get a file like mongo-cxx-driver-legacy.zip. Extract it to the folder mongo-cxx-driver-legacy inside your working directory.

您可以使用Git创建一个克隆,或者将它下载为.zip文件(我做了第二个)。您将得到一个类似mongo-cxx-driver-legacy.zip的文件。将其解压缩到工作目录中的mongo-cxx-driver-legacy文件夹。

  • Step 2
  • 步骤2

Download Boost prebuilt windows binaries. ATTENTION!!! You should use a specific version of Boost. In my case version 1.52 did the trick. You can download it from here:

下载Boost预构建的windows二进制文件。注意! ! !您应该使用特定版本的Boost。在我的案例中,1.52版本起到了作用。你可在此下载:

http://boost.teeks99.com/

http://boost.teeks99.com/

I downloaded the boost_1_52_0-vc32-bin.exe self-extracting exe. Put it on your working directory and run it. It will create a folder (something like lib32) that will contain the boost binaries (.lib and .dll files)

我下载了boost_1_52_0-vc32-bin。exe自解压exe。把它放在工作目录上并运行它。它将创建一个包含boost二进制文件的文件夹(类似于lib32)。*和. dll文件)

  • Step 3
  • 步骤3

Download Boost source code (.h files). Of course these should be from the same version as in Step 2. I downloaded them from here:

下载Boost源代码(。h文件)。当然,它们应该来自与第2步相同的版本。我从这里下载的:

http://sourceforge.net/projects/boost/files/boost/1.52.0/

http://sourceforge.net/projects/boost/files/boost/1.52.0/

You will get a file boost_1_52_0.zip which you can extract at boost_1_52_0 folder.

您将得到一个文件boost_1_52_0。可以在boost_1_52_0文件夹提取的zip。

  • Step 4
  • 步骤4

Download Python. In this example I downloaded version 2.7.9 and specifically the Windows x86 MSI installer from here:

下载Python。在本例中,我下载了2.7.9版本,特别是Windows x86 MSI安装程序:

https://www.python.org/downloads/release/python-279/

https://www.python.org/downloads/release/python-279/

  • Step 5
  • 步骤5

Download Scons from here:

从这里下载您:

http://www.scons.org/download.php

http://www.scons.org/download.php

I downloaded the Windows installer (scons-2.3.4-setup.exe) and installed Scons at the Python directory (in my case C:\Python27).

我下载了Windows安装程序(Scons -2.3.4 setup.exe),并在Python目录(在我的例子中是C:\Python27)安装了Scons。

  • Step 6
  • 步骤6

Download msinttypes from here:

从这里下载msinttypes:

https://code.google.com/p/msinttypes/

https://code.google.com/p/msinttypes/

(You should include these header files to the project that uses the driver)

(您应该将这些头文件包含到使用驱动程序的项目中)

  • Step 7
  • 步骤7

Go to Start->Run… and in the Run box write cmd. In the opened command prompt window navigate to the folder at which you extracted mongo driver at Step 1. In my case I did: cd D:\ D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy

去开始->运行…在运行框中写cmd。在打开的命令提示窗口中,导航到在步骤1提取mongo驱动程序的文件夹。在我的例子中,我做了:cd D:\ D:\MongoDBcplusplusClient\mongo- cxdriver -legacy\ mongox -driver-legacy

  • Step 8
  • 步骤8

Build the driver using Scons. In the directory you navigated at Step 7 write:

使用Scons构建驱动程序。在第7步导航的目录中写:

scons

--prefix=D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy

——prefix = D:\ MongoDBcplusplusClient \ mongo-cxx-driver-legacy \ mongo-cxx-driver-legacy

--cpppath=D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0

——cpppath = D:\ MongoDBcplusplusClient \ boost_1_52_0 \ boost_1_52_0

--libpath= D:\MongoDBcplusplusClient\lib32

——libpath = D:\ MongoDBcplusplusClient \ lib32

--win-version-min=xpsp3 install

——win-version-min = xpsp3安装

and hit Enter.

然后回车。

The --prefix flag specifies the target directory at which the .lib file of the driver will be created, --cpppath specifies the folder at which the Boost header files are located and the --libpath the path to Boost .lib files. Of course you should change the path to yours. A file named libmongoclient-s.lib will be created at the --prefix/lib path. If you want to build the driver with debugging enabled you should use the following command:

前缀标志指定要在其上创建驱动程序的.lib文件的目标目录,cpppath指定设置Boost头文件的文件夹,以及用于Boost .lib文件的-libpath。你当然应该改变你的道路。一个名为libmongoclient-s的文件。lib将在前缀/lib路径中创建。如果要构建启用调试的驱动程序,您应该使用以下命令:

scons

--prefix=D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy

——prefix = D:\ MongoDBcplusplusClient \ mongo-cxx-driver-legacy \ mongo-cxx-driver-legacy

--cpppath=D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0

——cpppath = D:\ MongoDBcplusplusClient \ boost_1_52_0 \ boost_1_52_0

--libpath= D:\MongoDBcplusplusClient\lib32

——libpath = D:\ MongoDBcplusplusClient \ lib32

--win-version-min=xpsp3

——win-version-min = xpsp3

--dbg=on install

在安装——dbg =

A file named libmongoclient-sgd.lib will be created at the --prefix/lib path.

一个名为libmongoclient-sgd的文件。lib将在-前缀/lib路径创建。

  • Step 9
  • 步骤9

At Windows Explorer navigate to the folder at which MongoDB C++ driver is installed, go into the subfolder lib (in my case this was D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy\lib) and rename the file libmongoclient-s.lib to mongoclient.lib and the libmongoclient-sgd.lib to mongoclient-gd.lib.

在Windows资源管理器中,导航到安装MongoDB c++驱动程序的文件夹,进入子文件夹lib(在我的例子中,这是D:\ mongodbcplusplusplusclient \mongo-cxx-driver-legacy\lib),并将文件命名为libmongoclient-s。mongoclient*。*和libmongoclient-sgd。mongoclient-gd.lib*。

  • Step 10
  • 第十步

Open Visual Studio 2010 Express and open the project at which you want to use the MongoDB C++ driver. You should specify the dependencies. Right click on project’s name at solution explorer (left column) and hit Properties. Go to C/C++ → General and at Additional Include Directories add:

打开Visual Studio 2010 Express并打开要使用MongoDB c++驱动程序的项目。您应该指定依赖项。在解决方案资源管理器(左列)右键单击项目名称并单击属性。去C / c++→将军和其他包括目录添加:

a) Boost header files directory (in my case D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0)

a) Boost头文件目录(在我的例子D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0)

b) MongoDB C++ driver header files directory (in my case D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver legacy\include)

b) MongoDB c++驱动头文件目录(在我的案例D:\ mongodbcplusplusplusclient \mongo-cxx-driver-legacy\mongo-cxx-driver legacy\include)

c) Cstdint types header files directory (in my case :\MongoDBcplusplusClient\msinttypes-r26 )

c) Cstdint类型头文件目录(在我的例子中是:\MongoDBcplusplusClient\ msinttyps -r26)

  • Step 11
  • 步骤11

Go to Linker → General and at Additional Library Directories add:

去链接器→一般和额外的图书馆目录添加:

a) Boost .lib files directory (in my case D:\MongoDBcplusplusClient\lib32)

a) Boost .lib文件目录(在我的例子D:\ mongodbcplusplusplusclient \lib32)

b) MongoDB C++ driver .lib files directory (in my case D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy\lib)

b) MongoDB c++ driver .lib文件目录(在我的情况下D:\ mongodbcplusplusplusclient \ mongoc -cxx-driver-legacy\lib)

After these steps the project that uses the driver will be successfully built both in release and debug configurations.

在这些步骤之后,使用驱动程序的项目将在发布和调试配置中成功构建。

#2


3  

Simple solution use vcpkg.

简单的解决方案使用vcpkg。

Download vcpkg follow the instructions as mentioned on git. https://github.com/Microsoft/vcpkg

按照git中提到的说明下载vcpkg。https://github.com/Microsoft/vcpkg

Step 1 C:\vcpkg>.\vcpkg search mongodb

步骤1 C:\ vcpkg >。mongodb \ vcpkg搜索

you will see something like that

你会看到类似的东西

mongo-c-driver 1.6.2-1 Client library written in C for MongoDB.

蒙古- C -driver 1.6.2-1客户端库,用C编写,用于MongoDB。

mongo-cxx-driver 3.1.1-1 MongoDB C++ Driver.

MongoDB c++驱动程序3.1.1-1 MongoDB c++驱动程序。

Step 2 C:.\vcpkg search mongodb install mongo-cxx-driver

步骤2 C:。搜索mongodb安装mongodb -cxx驱动程序

then grab cup of coffee ....

然后抓起一杯咖啡....

Stap 3

堵塞3

C:\vcpkg>.\vcpkg integrate install

C:\ vcpkg >。\ vcpkg集成安装

Done..

做. .

Note Prerequisites:

注意先决条件:

Windows 10, 8.1, or 7

Windows 10、8.1或7

Visual Studio 2017 or Visual Studio 2015 Update 3

Visual Studio 2017或Visual Studio 2015更新3。

simply import

简单的导入

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

#1


9  

How to build MongoDB C++ driver

如何构建MongoDB c++驱动程序

This solution succeeded on a machine with the following characteristics:

该解决方案在一台具有以下特点的机器上获得成功:

  1. Windows XP SP3 32-bit
  2. Windows XP SP3 32位
  3. Visual Studio Express 2010 (VC 10)
  4. Visual Studio Express 2010 (vc10)

I used D:\MongoDBcplusplusClient as a working directory (I installed there all the prerequisites).

我使用了D:\ mongodbcplusplusplusclient作为工作目录(我在那里安装了所有的先决条件)。

Process:

过程:

  • Step 1
  • 步骤1

Download MongoDB C++ driver:

下载MongoDB c++司机:

https://github.com/mongodb/mongo-cxx-driver

https://github.com/mongodb/mongo-cxx-driver

You can make a clone using Git or download it as a .zip file (I did the second).You will get a file like mongo-cxx-driver-legacy.zip. Extract it to the folder mongo-cxx-driver-legacy inside your working directory.

您可以使用Git创建一个克隆,或者将它下载为.zip文件(我做了第二个)。您将得到一个类似mongo-cxx-driver-legacy.zip的文件。将其解压缩到工作目录中的mongo-cxx-driver-legacy文件夹。

  • Step 2
  • 步骤2

Download Boost prebuilt windows binaries. ATTENTION!!! You should use a specific version of Boost. In my case version 1.52 did the trick. You can download it from here:

下载Boost预构建的windows二进制文件。注意! ! !您应该使用特定版本的Boost。在我的案例中,1.52版本起到了作用。你可在此下载:

http://boost.teeks99.com/

http://boost.teeks99.com/

I downloaded the boost_1_52_0-vc32-bin.exe self-extracting exe. Put it on your working directory and run it. It will create a folder (something like lib32) that will contain the boost binaries (.lib and .dll files)

我下载了boost_1_52_0-vc32-bin。exe自解压exe。把它放在工作目录上并运行它。它将创建一个包含boost二进制文件的文件夹(类似于lib32)。*和. dll文件)

  • Step 3
  • 步骤3

Download Boost source code (.h files). Of course these should be from the same version as in Step 2. I downloaded them from here:

下载Boost源代码(。h文件)。当然,它们应该来自与第2步相同的版本。我从这里下载的:

http://sourceforge.net/projects/boost/files/boost/1.52.0/

http://sourceforge.net/projects/boost/files/boost/1.52.0/

You will get a file boost_1_52_0.zip which you can extract at boost_1_52_0 folder.

您将得到一个文件boost_1_52_0。可以在boost_1_52_0文件夹提取的zip。

  • Step 4
  • 步骤4

Download Python. In this example I downloaded version 2.7.9 and specifically the Windows x86 MSI installer from here:

下载Python。在本例中,我下载了2.7.9版本,特别是Windows x86 MSI安装程序:

https://www.python.org/downloads/release/python-279/

https://www.python.org/downloads/release/python-279/

  • Step 5
  • 步骤5

Download Scons from here:

从这里下载您:

http://www.scons.org/download.php

http://www.scons.org/download.php

I downloaded the Windows installer (scons-2.3.4-setup.exe) and installed Scons at the Python directory (in my case C:\Python27).

我下载了Windows安装程序(Scons -2.3.4 setup.exe),并在Python目录(在我的例子中是C:\Python27)安装了Scons。

  • Step 6
  • 步骤6

Download msinttypes from here:

从这里下载msinttypes:

https://code.google.com/p/msinttypes/

https://code.google.com/p/msinttypes/

(You should include these header files to the project that uses the driver)

(您应该将这些头文件包含到使用驱动程序的项目中)

  • Step 7
  • 步骤7

Go to Start->Run… and in the Run box write cmd. In the opened command prompt window navigate to the folder at which you extracted mongo driver at Step 1. In my case I did: cd D:\ D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy

去开始->运行…在运行框中写cmd。在打开的命令提示窗口中,导航到在步骤1提取mongo驱动程序的文件夹。在我的例子中,我做了:cd D:\ D:\MongoDBcplusplusClient\mongo- cxdriver -legacy\ mongox -driver-legacy

  • Step 8
  • 步骤8

Build the driver using Scons. In the directory you navigated at Step 7 write:

使用Scons构建驱动程序。在第7步导航的目录中写:

scons

--prefix=D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy

——prefix = D:\ MongoDBcplusplusClient \ mongo-cxx-driver-legacy \ mongo-cxx-driver-legacy

--cpppath=D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0

——cpppath = D:\ MongoDBcplusplusClient \ boost_1_52_0 \ boost_1_52_0

--libpath= D:\MongoDBcplusplusClient\lib32

——libpath = D:\ MongoDBcplusplusClient \ lib32

--win-version-min=xpsp3 install

——win-version-min = xpsp3安装

and hit Enter.

然后回车。

The --prefix flag specifies the target directory at which the .lib file of the driver will be created, --cpppath specifies the folder at which the Boost header files are located and the --libpath the path to Boost .lib files. Of course you should change the path to yours. A file named libmongoclient-s.lib will be created at the --prefix/lib path. If you want to build the driver with debugging enabled you should use the following command:

前缀标志指定要在其上创建驱动程序的.lib文件的目标目录,cpppath指定设置Boost头文件的文件夹,以及用于Boost .lib文件的-libpath。你当然应该改变你的道路。一个名为libmongoclient-s的文件。lib将在前缀/lib路径中创建。如果要构建启用调试的驱动程序,您应该使用以下命令:

scons

--prefix=D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy

——prefix = D:\ MongoDBcplusplusClient \ mongo-cxx-driver-legacy \ mongo-cxx-driver-legacy

--cpppath=D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0

——cpppath = D:\ MongoDBcplusplusClient \ boost_1_52_0 \ boost_1_52_0

--libpath= D:\MongoDBcplusplusClient\lib32

——libpath = D:\ MongoDBcplusplusClient \ lib32

--win-version-min=xpsp3

——win-version-min = xpsp3

--dbg=on install

在安装——dbg =

A file named libmongoclient-sgd.lib will be created at the --prefix/lib path.

一个名为libmongoclient-sgd的文件。lib将在-前缀/lib路径创建。

  • Step 9
  • 步骤9

At Windows Explorer navigate to the folder at which MongoDB C++ driver is installed, go into the subfolder lib (in my case this was D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy\lib) and rename the file libmongoclient-s.lib to mongoclient.lib and the libmongoclient-sgd.lib to mongoclient-gd.lib.

在Windows资源管理器中,导航到安装MongoDB c++驱动程序的文件夹,进入子文件夹lib(在我的例子中,这是D:\ mongodbcplusplusplusclient \mongo-cxx-driver-legacy\lib),并将文件命名为libmongoclient-s。mongoclient*。*和libmongoclient-sgd。mongoclient-gd.lib*。

  • Step 10
  • 第十步

Open Visual Studio 2010 Express and open the project at which you want to use the MongoDB C++ driver. You should specify the dependencies. Right click on project’s name at solution explorer (left column) and hit Properties. Go to C/C++ → General and at Additional Include Directories add:

打开Visual Studio 2010 Express并打开要使用MongoDB c++驱动程序的项目。您应该指定依赖项。在解决方案资源管理器(左列)右键单击项目名称并单击属性。去C / c++→将军和其他包括目录添加:

a) Boost header files directory (in my case D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0)

a) Boost头文件目录(在我的例子D:\MongoDBcplusplusClient\boost_1_52_0\boost_1_52_0)

b) MongoDB C++ driver header files directory (in my case D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver legacy\include)

b) MongoDB c++驱动头文件目录(在我的案例D:\ mongodbcplusplusplusclient \mongo-cxx-driver-legacy\mongo-cxx-driver legacy\include)

c) Cstdint types header files directory (in my case :\MongoDBcplusplusClient\msinttypes-r26 )

c) Cstdint类型头文件目录(在我的例子中是:\MongoDBcplusplusClient\ msinttyps -r26)

  • Step 11
  • 步骤11

Go to Linker → General and at Additional Library Directories add:

去链接器→一般和额外的图书馆目录添加:

a) Boost .lib files directory (in my case D:\MongoDBcplusplusClient\lib32)

a) Boost .lib文件目录(在我的例子D:\ mongodbcplusplusplusclient \lib32)

b) MongoDB C++ driver .lib files directory (in my case D:\MongoDBcplusplusClient\mongo-cxx-driver-legacy\mongo-cxx-driver-legacy\lib)

b) MongoDB c++ driver .lib文件目录(在我的情况下D:\ mongodbcplusplusplusclient \ mongoc -cxx-driver-legacy\lib)

After these steps the project that uses the driver will be successfully built both in release and debug configurations.

在这些步骤之后,使用驱动程序的项目将在发布和调试配置中成功构建。

#2


3  

Simple solution use vcpkg.

简单的解决方案使用vcpkg。

Download vcpkg follow the instructions as mentioned on git. https://github.com/Microsoft/vcpkg

按照git中提到的说明下载vcpkg。https://github.com/Microsoft/vcpkg

Step 1 C:\vcpkg>.\vcpkg search mongodb

步骤1 C:\ vcpkg >。mongodb \ vcpkg搜索

you will see something like that

你会看到类似的东西

mongo-c-driver 1.6.2-1 Client library written in C for MongoDB.

蒙古- C -driver 1.6.2-1客户端库,用C编写,用于MongoDB。

mongo-cxx-driver 3.1.1-1 MongoDB C++ Driver.

MongoDB c++驱动程序3.1.1-1 MongoDB c++驱动程序。

Step 2 C:.\vcpkg search mongodb install mongo-cxx-driver

步骤2 C:。搜索mongodb安装mongodb -cxx驱动程序

then grab cup of coffee ....

然后抓起一杯咖啡....

Stap 3

堵塞3

C:\vcpkg>.\vcpkg integrate install

C:\ vcpkg >。\ vcpkg集成安装

Done..

做. .

Note Prerequisites:

注意先决条件:

Windows 10, 8.1, or 7

Windows 10、8.1或7

Visual Studio 2017 or Visual Studio 2015 Update 3

Visual Studio 2017或Visual Studio 2015更新3。

simply import

简单的导入

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