1

I'm trying to run the example program for the MongoDB C++ Driver so I can run some tests, and have come across some errors that I'm stuck on.

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

Here's the code

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

Before anyone asks, I have the Boost Libraries and Headers referenced and they seem to work fine. I have also referenced the Mongo libraries and Headers.

Additional Include Directories: Boost and Mongo Source

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

Anyone have any clues? Do I have to include the dbclient.obj file in Additional Dependencies? When I do I get like 96 new errors. I think I might be missing some .dll but can't figure out what.

Would appreciate any help as this is only a small part of a much larger project.

2 Answers2

0

Try:

  1. 32 vs 64 bit mismatch.
  2. I got similar problem when used MS VC Compiler against old libraries. Solution was to get latest libraries.
Boris Ivanov
  • 4,145
  • 1
  • 32
  • 40
0

My success story is: MS Visual Studio 2015 + mongo-cxx-driver-26compat (builded as 32 bit DLL) + 32 bit DLLs from boost_1_59_0.

b_ma_n_s
  • 21
  • 3