1

I've been trying to use MongoCXX r3.1.2 with Mongo-C 1.4.2 on Windows with MSVC but with no luck.

I get about 2,000 linker errors when I try to use it in a project.

The errors:

1>------ Build started: Project: Mongo, Configuration: Debug x64 ------ 1>main.cpp 1>libmongocxx.lib(find.obj) : error LNK2001: unresolved external symbol __imp_mongoc_read_prefs_new 1>libmongocxx.lib(index.obj) : error LNK2001: unresolved external symbol __imp_mongoc_read_prefs_new
https://pastebin.com/tkVyfuqj

I tried using the new Mongo-C driver (1.7.0-r2) and I got the same result. The project is also 64-bit. Even after I copy the include directories right from the documentation I get the same thing. I'm using Visual Studio 2017, does anybody have any ideas?

Community
  • 1
  • 1
postman300
  • 11
  • 1
  • Carefully double check everything to ensure that you are building the C driver, the C++ driver, and your application with unreasonable consistency as to Debug vs Release, DLL vs Static, etc. Most often, these sort of linking errors are due to subtle incompatibilities. Note also that macros may need to be defined to link against the static versions of the libraries. – acm Aug 02 '17 at 00:40

1 Answers1

1

Looks like your driver didn't compile correctly. Try this...

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

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

you will see something like that

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

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

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

then grab cup of coffee ....

Stap 3

C:\vcpkg>.\vcpkg integrate install

Done..

Note Prerequisites:

Windows 10, 8.1, or 7

Visual Studio 2017 or Visual Studio 2015 Update 3

simply import.

Answered by @JoyoWaseem here

Joyo Waseem
  • 680
  • 8
  • 25