mongodb v3驱动程序vc ++社区添加链接器错误

时间:2017-10-11 15:53:03

标签: mongodb visual-c++ driver mongo-cxx-driver

我在vc ++ 2017中编译时在types.hpp中遇到以下链接器错误。我该如何解决?

以下是我在vc ++中编译的代码。

包括其他目录。

E:\ boost_1_61_0彬MSVC-全32-64 \ boost_1_61_0; E:\ nosql_db \ mongocxx-驾驶员r3.1.3 \包括\ mongocxx \ v_noabi; E:\ nosql_db \蒙戈-cxx-驾驶员r3.1.3 \包括\ bsoncxx \ v_noabi; E:\ nosql_db \周一-C-驱动\包括\ libbson-1.0; E:\ nosql_db \周一-C-驱动\包括\ libmongoc-1.0;%(AdditionalDependencies)

#include "stdafx.h"
#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>

using bsoncxx::builder::stream::document;

int main()
{
    mongocxx::instance inst{};
    mongocxx::client conn{ mongocxx::uri{} };

    bsoncxx::builder::stream::document document{};

    auto collection = conn["testdb"]["testcollection"];
    document << "hello" << "world";

    collection.insert_one(document.view());
    auto cursor = collection.find({});

    for (auto&& doc : cursor) {
        std::cout << bsoncxx::to_json(doc) << std::endl;
    }
    return 0;
}


everity Code    Description Project File    Line    Suppression State
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_double::type_id" may not be initialized  textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   86  
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_utf8::type_id" may not be initialized    textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   111 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_document::type_id" may not be initialized    textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   149 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_array::type_id" may not be initialized   textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   181 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_binary::type_id" may not be initialized  textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   206 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_undefined::type_id" may not be initialized   textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   230 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_oid::type_id" may not be initialized textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   246 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_bool::type_id" may not be initialized    textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   264 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_date::type_id" may not be initialized    textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   289 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_null::type_id" may not be initialized    textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   350 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_regex::type_id" may not be initialized   textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   366 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_dbpointer::type_id" may not be initialized   textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   402 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_code::type_id" may not be initialized    textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   421 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_symbol::type_id" may not be initialized  textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   462 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_codewscope::type_id" may not be initialized  textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   500 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_int32::type_id" may not be initialized   textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   533 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_timestamp::type_id" may not be initialized   textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   562 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_int64::type_id" may not be initialized   textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   581 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_decimal128::type_id" may not be initialized  textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   606 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_minkey::type_id" may not be initialized  textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   637 
Error (active)  E0145   member "bsoncxx::v_noabi::types::b_maxkey::type_id" may not be initialized  textapp e:\nosql_db\mongo-cxx-driver-r3.1.3\include\bsoncxx\v_noabi\bsoncxx\types.hpp   653 
Error   LNK1107 invalid or corrupt file: cannot read at 0x398   textapp E:\nosql_db\mongo-cxx-driver-r3.1.3\bin\mongocxx.dll    1   

安装驱动程序的步骤。

cmake -G "Visual Studio 14 2015 Win64" "-DCMAKE_INSTALL_PREFIX=E:\\nosql_db\\mongo-c-driver" "-DCMAKE_BUILD_TYPE=Release"
msbuild.exe /p:Configuration=Release ALL_BUILD.vcxproj
msbuild.exe /p:Configuration=Release INSTALL.vcxproj
cmake -G "Visual Studio 14 2015 Win64" "-DENABLE_SSL=WINDOWS" "-DENABLE_SASL=SSPI" "-DCMAKE_INSTALL_PREFIX=E:\\nosql_db\\mongo-c-driver1" "-DCMAKE_PREFIX_PATH=E:\\nosql_db\\mongo-c-driver" "-DCMAKE_BUILD_TYPE=Release"
msbuild.exe /p:Configuration=Release ALL_BUILD.vcxproj
msbuild.exe /p:Configuration=Release INSTALL.vcxproj
cmake.exe -G "Visual Studio 14 Win64" -DCMAKE_INSTALL_PREFIX=E:\\nosql_db\\mongo-cxx-driver1 -DCMAKE_PREFIX_PATH=E:\\nosql_db\\mon-c-driver -DBOOST_ROOT=E:\\boost_1_65_1
msbuild.exe ALL_BUILD.vcxproj
msbuild.exe INSTALL.vcxproj

然后在vc ++配置中添加了其他库。

E:\nosql_db\mongo-cxx-driver1\include\bsoncxx\v_noabi;E:\nosql_db\mongo-cxx-driver1\include\mongocxx\v_noabi;E:\nosql_db\mon-c-driver\include\libbson-1.0;E:\nosql_db\mon-c-driver\include\libmongoc-1.0;

E:\nosql_db\mongo-cxx-driver1\bin\mongocxx.dll;E:\nosql_db\mongo-cxx-driver1\bin\bsoncxx.dll;E:\nosql_db\mon-c-driver\bin\libbson-1.0.dll;E:\nosql_db\mon-c-driver\bin\libmongoc-1.0.dll;

以下是我的链接器设置:

   /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"E:\workouts\cpp\textapp\textapp\x64\Release\textapp.pdb" /DYNAMICBASE "mongocxx.dll" "bsoncxx.dll" "libbson-1.0.dll" "libmongoc-1.0.dll" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /IMPLIB:"E:\nosql_db\mongo-cxx-driver1\bin\mongocxx.dll;E:\nosql_db\mongo-cxx-driver1\bin\bsoncxx.dll;E:\nosql_db\mon-c-driver\bin\libbson-1.0.dll;E:\nosql_db\mon-c-driver\bin\libmongoc-1.0.dll;" /DEBUG:FULL /MACHINE:X64 /OPT:REF /INCREMENTAL:NO /PGD:"E:\workouts\cpp\textapp\textapp\x64\Release\textapp.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\textapp.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"E:\nosql_db\mongo-cxx-driver1\lib\bsoncxx.lib" /LIBPATH:"E:\nosql_db\mongo-cxx-driver1\lib\libbsoncxx.lib" /LIBPATH:"E:\nosql_db\mongo-cxx-driver1\lib\libmongocxx.lib" /LIBPATH:"E:\nosql_db\mongo-cxx-driver1\lib\mongocxx.lib" /LIBPATH:"E:\nosql_db\mon-c-driver\lib\bson-1.0.lib" /LIBPATH:"E:\nosql_db\mon-c-driver\lib\mongoc-1.0.lib" /TLBID:1 

0 个答案:

没有答案