gpt4 book ai didi

c++ - MongoDB C++ 驱动程序 - 未解析的外部符号

转载 作者:太空宇宙 更新时间:2023-11-04 13:55:37 25 4
gpt4 key购买 nike

我正在尝试运行 MongoDB C++ 驱动程序的示例程序,以便我可以运行一些测试,但遇到了一些我卡住的错误。

Error   1   error LNK2019: unresolved external symbol "__declspec(dllimport)     public: __thiscall mongo::DBClientConnection::DBClientConnection(bool,class     mongo::DBClientReplicaSet *,double)" (__imp_??0DBClientConnection@mongo@@QAE@_NPAVDBClientReplicaSet@1@N@Z) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)  E:\Programming\C++\BoostTest\BoostTest\BoostTest\Testcpp.obj    BoostTest

Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall mongo::DBClientConnection::~DBClientConnection(void)" (__imp_??1DBClientConnection@mongo@@UAE@XZ) referenced in function "void __cdecl run(void)" (?run@@YAXXZ) E:\Programming\C++\BoostTest\BoostTest\BoostTest\Testcpp.obj BoostTest

Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall mongo::DBClientConnection::connect(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?connect@DBClientConnection@mongo@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "void __cdecl run(void)" (?run@@YAXXZ) E:\Programming\C++\BoostTest\BoostTest\BoostTest\Testcpp.obj BoostTest

这是代码

#include <cstdlib>
#include <iostream>
#include "mongo\client\dbclient.h"

#define BOOST_ALL_DYN_LINK

void run()
{
mongo::DBClientConnection c;
c.connect("localhost");
}

int main()
{
try
{
run();
std::cout << "Connected" << std::endl;
}
catch(const mongo::DBException &e)
{
std::cout << "caught " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}

在任何人询问之前,我已经引用了 Boost 库和 header ,它们似乎工作正常。我还引用了 Mongo 库和 header 。

Additional Include Directories: Boost and Mongo Source

Linker Additional Library Directories: boost/stage/lib and Mongo build client

有人知道吗?我是否必须在附加依赖项中包含 dbclient.obj 文件?当我这样做时,我得到了 96 个新错误。我想我可能缺少一些 .dll,但不知道是什么。

感谢任何帮助,因为这只是一个更大项目的一小部分。

最佳答案

尝试:

  1. 32 位与 64 位不匹配。
  2. 我在对旧库使用 MS VC 编译器时遇到了类似的问题。解决方案是获取最新的库。

关于c++ - MongoDB C++ 驱动程序 - 未解析的外部符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21634336/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com